Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function() {
- 'use strict';
- angular.module('schedules')
- .factory('TimeServiceMatchers', TimeServiceMatchers);
- TimeServiceMatchers.$inject = [];
- function TimeServiceMatchers() {
- return {
- getMatchers: getMatchers
- }
- function getMatchers() {
- return {
- toEndIn: toEndIn,
- toHaveMinutesOf30or00: toHaveMinutesOf30or00
- }
- }
- function toEndIn() {
- return {
- compare: compare
- }
- function compare(actual, expected) {
- const aOrP = expected.replace(/[m]/, '');
- const reversedArray = actual.split('').reverse();
- return {
- pass: (reversedArray[0] === 'm' && reversedArray[1] === aOrP),
- message: actual + ' does not end in ' + aOrP + 'm'
- };
- }
- }
- function toHaveMinutesOf30or00() {
- return {
- compare: compare
- }
- function compare(actual) {
- const minutes = actual.replace(/.*:/, '').replace(/(am|pm)/gi, '');
- return {
- pass: (minutes === '30' || minutes === '00'),
- message: actual + ' does not have minutes of 30 or 00'
- };
- }
- }
- }
- })();
Add Comment
Please, Sign In to add comment