0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-11 02:12:21 -05:00

Renamed e2e framework date matchers

refs f48892028d
refs 33da584161

- There was another mather added recently: anyDateWithTimezoneOffset. The naming of date-related matchers was getting long and confusing. Renamed existing date matcher to better reflect what they do and they types of matches they are responsible for, following renames have been done:
- anyShortDate  -> anyISODate
- anyDate  -> anyISODateTime
- anyDateWithTimezoneOffset  -> anyISODateTimeWithTZ
This commit is contained in:
Naz 2022-03-01 18:17:13 +07:00
parent a17ef130f9
commit b3bf19e9e3
6 changed files with 51 additions and 51 deletions

View file

@ -1,5 +1,5 @@
const {agentProvider, mockManager, fixtureManager, matchers} = require('../../utils/e2e-framework');
const {anyEtag, anyObjectId, anyUuid, anyDate, anyShortDate, anyString, anyArray, anyLocationFor, anyErrorId} = matchers;
const {anyEtag, anyObjectId, anyUuid, anyISODateTime, anyISODate, anyString, anyArray, anyLocationFor, anyErrorId} = matchers;
const assert = require('assert');
const nock = require('nock');
@ -24,15 +24,15 @@ async function assertEvents({eventType, eventName, quantity, asserts}) {
const memberMatcherNoIncludes = {
id: anyObjectId,
uuid: anyUuid,
created_at: anyDate,
updated_at: anyDate
created_at: anyISODateTime,
updated_at: anyISODateTime
};
const memberMatcherShallowIncludes = {
id: anyObjectId,
uuid: anyUuid,
created_at: anyDate,
updated_at: anyDate,
created_at: anyISODateTime,
updated_at: anyISODateTime,
subscriptions: anyArray,
labels: anyArray
};
@ -110,8 +110,8 @@ describe('Members API', function () {
members: new Array(8).fill({
id: anyObjectId,
uuid: anyUuid,
created_at: anyDate,
updated_at: anyDate,
created_at: anyISODateTime,
updated_at: anyISODateTime,
labels: anyArray,
subscriptions: anyArray
})
@ -129,8 +129,8 @@ describe('Members API', function () {
members: new Array(1).fill({
id: anyObjectId,
uuid: anyUuid,
created_at: anyDate,
updated_at: anyDate,
created_at: anyISODateTime,
updated_at: anyISODateTime,
labels: anyArray,
subscriptions: anyArray
})
@ -148,8 +148,8 @@ describe('Members API', function () {
members: new Array(1).fill({
id: anyObjectId,
uuid: anyUuid,
created_at: anyDate,
updated_at: anyDate,
created_at: anyISODateTime,
updated_at: anyISODateTime,
labels: anyArray,
subscriptions: anyArray
})
@ -167,8 +167,8 @@ describe('Members API', function () {
members: new Array(5).fill({
id: anyObjectId,
uuid: anyUuid,
created_at: anyDate,
updated_at: anyDate,
created_at: anyISODateTime,
updated_at: anyISODateTime,
labels: anyArray,
subscriptions: anyArray
})
@ -268,8 +268,8 @@ describe('Members API', function () {
members: new Array(1).fill({
id: anyObjectId,
uuid: anyUuid,
created_at: anyDate,
updated_at: anyDate,
created_at: anyISODateTime,
updated_at: anyISODateTime,
labels: anyArray,
subscriptions: anyArray
})
@ -287,8 +287,8 @@ describe('Members API', function () {
members: new Array(1).fill({
id: anyObjectId,
uuid: anyUuid,
created_at: anyDate,
updated_at: anyDate,
created_at: anyISODateTime,
updated_at: anyISODateTime,
labels: anyArray,
subscriptions: anyArray
})
@ -317,8 +317,8 @@ describe('Members API', function () {
members: new Array(1).fill({
id: anyObjectId,
uuid: anyUuid,
created_at: anyDate,
updated_at: anyDate,
created_at: anyISODateTime,
updated_at: anyISODateTime,
labels: anyArray,
subscriptions: anyArray
})
@ -483,8 +483,8 @@ describe('Members API', function () {
members: new Array(1).fill({
id: anyObjectId,
uuid: anyUuid,
created_at: anyDate,
updated_at: anyDate,
created_at: anyISODateTime,
updated_at: anyISODateTime,
labels: anyArray,
subscriptions: anyArray
})
@ -504,8 +504,8 @@ describe('Members API', function () {
members: new Array(1).fill({
id: anyObjectId,
uuid: anyUuid,
created_at: anyDate,
updated_at: anyDate,
created_at: anyISODateTime,
updated_at: anyISODateTime,
labels: anyArray,
subscriptions: anyArray
})
@ -558,8 +558,8 @@ describe('Members API', function () {
members: new Array(1).fill({
id: anyObjectId,
uuid: anyUuid,
created_at: anyDate,
updated_at: anyDate,
created_at: anyISODateTime,
updated_at: anyISODateTime,
labels: anyArray,
subscriptions: anyArray
})
@ -598,8 +598,8 @@ describe('Members API', function () {
members: new Array(1).fill({
id: anyObjectId,
uuid: anyUuid,
created_at: anyDate,
updated_at: anyDate,
created_at: anyISODateTime,
updated_at: anyISODateTime,
labels: anyArray,
subscriptions: anyArray
})
@ -678,8 +678,8 @@ describe('Members API', function () {
members: new Array(1).fill({
id: anyObjectId,
uuid: anyUuid,
created_at: anyDate,
updated_at: anyDate,
created_at: anyISODateTime,
updated_at: anyISODateTime,
labels: anyArray,
subscriptions: [{
start_date: anyString,
@ -714,8 +714,8 @@ describe('Members API', function () {
members: new Array(1).fill({
id: anyObjectId,
uuid: anyUuid,
created_at: anyDate,
updated_at: anyDate,
created_at: anyISODateTime,
updated_at: anyISODateTime,
labels: anyArray,
subscriptions: anyArray
})
@ -832,7 +832,7 @@ describe('Members API', function () {
.expectStatus(200)
.matchBodySnapshot({
data: [{
date: anyShortDate
date: anyISODate
}]
})
.matchHeaderSnapshot({

View file

@ -29,8 +29,8 @@ describe('Tiers API', function () {
.matchBodySnapshot({
tiers: Array(2).fill({
id: matchers.anyObjectId,
created_at: matchers.anyDate,
updated_at: matchers.anyDate
created_at: matchers.anyISODateTime,
updated_at: matchers.anyISODateTime
})
});
});

View file

@ -1,12 +1,12 @@
const assert = require('assert');
const {agentProvider, fixtureManager, matchers} = require('../../utils/e2e-framework');
const {anyEtag, anyUuid, anyDateWithTimezoneOffset} = matchers;
const {anyEtag, anyUuid, anyISODateTimeWithTZ} = matchers;
const pageMatcher = {
published_at: anyDateWithTimezoneOffset,
created_at: anyDateWithTimezoneOffset,
updated_at: anyDateWithTimezoneOffset,
published_at: anyISODateTimeWithTZ,
created_at: anyISODateTimeWithTZ,
updated_at: anyISODateTimeWithTZ,
uuid: anyUuid
};

View file

@ -3,12 +3,12 @@ const cheerio = require('cheerio');
const moment = require('moment');
const {agentProvider, fixtureManager, matchers} = require('../../utils/e2e-framework');
const {anyArray, anyEtag, anyUuid, anyDateWithTimezoneOffset} = matchers;
const {anyArray, anyEtag, anyUuid, anyISODateTimeWithTZ} = matchers;
const postMatcher = {
published_at: anyDateWithTimezoneOffset,
created_at: anyDateWithTimezoneOffset,
updated_at: anyDateWithTimezoneOffset,
published_at: anyISODateTimeWithTZ,
created_at: anyISODateTimeWithTZ,
updated_at: anyISODateTimeWithTZ,
uuid: anyUuid
};

View file

@ -1,7 +1,7 @@
const nock = require('nock');
const assert = require('assert');
const {agentProvider, mockManager, fixtureManager, matchers} = require('../../../utils/e2e-framework');
const {anyEtag, anyDate, anyErrorId} = matchers;
const {anyEtag, anyISODateTime, anyErrorId} = matchers;
const {tokens} = require('@tryghost/security');
const models = require('../../../../core/server/models');
@ -56,8 +56,8 @@ describe('Authentication API', function () {
.expectStatus(201)
.matchBodySnapshot({
users: [{
created_at: anyDate,
updated_at: anyDate
created_at: anyISODateTime,
updated_at: anyISODateTime
}]
})
.matchHeaderSnapshot({
@ -127,9 +127,9 @@ describe('Authentication API', function () {
.expectStatus(200)
.matchBodySnapshot({
users: [{
created_at: anyDate,
last_seen: anyDate,
updated_at: anyDate
created_at: anyISODateTime,
last_seen: anyISODateTime,
updated_at: anyISODateTime
}]
})
.matchHeaderSnapshot({

View file

@ -276,9 +276,9 @@ module.exports = {
matchers: {
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}/),
anyDateWithTimezoneOffset: stringMatching(/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.000\+\d{2}:\d{2}/),
anyISODateTime: stringMatching(/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.000Z/),
anyISODate: stringMatching(/\d{4}-\d{2}-\d{2}/),
anyISODateTimeWithTZ: stringMatching(/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.000\+\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}/),