-
Notifications
You must be signed in to change notification settings - Fork 22
/
ticket.test.js
22 lines (18 loc) · 1.02 KB
/
ticket.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const test = require('ava');
const { mergeTicketStatus } = require('./ticket');
test('mergeTicketStatus should keep old length', t => {
const expect = 2;
const oldTicketStatus = [{}, {}];
const newTicketStatus = [{}];
t.deepEqual(expect, mergeTicketStatus(oldTicketStatus, newTicketStatus).length);
})
test('mergeTicketStatus should use newStatus first', t => {
const oldTicketStatus = [{ "date": "2017/08/25(六)", "sport": "田徑", "place": "臺北田徑場", "hasTicket": true }];
const newTicketStatus = [{ "date": "2017/08/25(六)", "sport": "田徑", "place": "臺北田徑場", "hasTicket": false }];
t.false(mergeTicketStatus(oldTicketStatus, newTicketStatus)[0].hasTicket);
})
test('mergeTicketStatus if no match for oldTicket, hasTicket should be false', t => {
const oldTicketStatus = [{ "date": "2017/08/25(五)", "sport": "田徑", "place": "臺北田徑場", "hasTicket": true }];
const newTicketStatus = [];
t.false(mergeTicketStatus(oldTicketStatus, newTicketStatus)[0].hasTicket);
})