mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05:00
Fixed failing snapshot match in members
no issue - The test was failing because the match for a the data has changed, which was returned in a short format YYYY-MM-DD. - Added a new matcher for short date format -anyShortDate. Can be used for match dynamic dates in short format
This commit is contained in:
parent
d54c1efefb
commit
f48892028d
3 changed files with 8 additions and 3 deletions
|
@ -797,7 +797,7 @@ Object {
|
|||
"data": Array [
|
||||
Object {
|
||||
"comped": 0,
|
||||
"date": "2022-02-17",
|
||||
"date": StringMatching /\\\\d\\{4\\}-\\\\d\\{2\\}-\\\\d\\{2\\}/,
|
||||
"free": 2,
|
||||
"paid": 1,
|
||||
},
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const {agentProvider, mockManager, fixtureManager, matchers} = require('../../utils/e2e-framework');
|
||||
const {anyEtag, anyObjectId, anyUuid, anyDate, anyString, anyArray, anyLocationFor, anyErrorId} = matchers;
|
||||
const {anyEtag, anyObjectId, anyUuid, anyDate, anyShortDate, anyString, anyArray, anyLocationFor, anyErrorId} = matchers;
|
||||
|
||||
const assert = require('assert');
|
||||
const nock = require('nock');
|
||||
|
@ -719,7 +719,11 @@ describe('Members API', function () {
|
|||
await agent
|
||||
.get(`/members/stats/count/`)
|
||||
.expectStatus(200)
|
||||
.matchBodySnapshot()
|
||||
.matchBodySnapshot({
|
||||
data: [{
|
||||
date: anyShortDate
|
||||
}]
|
||||
})
|
||||
.matchHeaderSnapshot({
|
||||
etag: anyEtag
|
||||
});
|
||||
|
|
|
@ -253,6 +253,7 @@ module.exports = {
|
|||
anyString: any(String),
|
||||
anyArray: any(Array),
|
||||
anyDate: stringMatching(/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.000Z/),
|
||||
anyShortDate: stringMatching(/\d{4}-\d{2}-\d{2}/),
|
||||
anyEtag: stringMatching(/(?:W\/)?"(?:[ !#-\x7E\x80-\xFF]*|\r\n[\t ]|\\.)*"/),
|
||||
anyObjectId: stringMatching(/[a-f0-9]{24}/),
|
||||
anyErrorId: stringMatching(/[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}/),
|
||||
|
|
Loading…
Add table
Reference in a new issue