How to use wks method in wpt

Best JavaScript code snippet using wpt

timetable-parsers.spec.ts

Source:timetable-parsers.spec.ts Github

copy

Full Screen

1import * as cheerio from 'cheerio';2import { Day, IModuleDetails, IModuleExamTimetable, IWeekDate, LessonType } from '../../src';3import {4 parseCourseTimetableLesson,5 parseModuleDetails,6 parseModuleExamTimetable,7 parseModuleTimetableLesson,8 parseRoomTimetableLesson,9 parseStudentExamTimetable,10 parseStudentTimetableLesson,11 parseTimetable,12 parseWeekDates,13} from '../../src/util/timetable-parsers';14import {15 courseTimetableGroupLesson,16 courseTimetableLesson,17 moduleTimetableGroupLesson,18 moduleTimetableLesson,19 roomTimetableBooking,20 roomTimetableLesson,21 studentTimetableGroupLesson,22 studentTimetableLesson,23} from '../html/timetable-lessons';24import {25 courseTimetable,26 moduleDetails,27 moduleExamTimetable,28 moduleTimetable,29 nullTimetable,30 roomTimetable,31 studentExamTimetable,32 studentTimetable,33 weekDates,34} from '../html/timetables';35describe('parseWeekDates()', () => {36 const $ = cheerio.load(weekDates);37 const mockWeeks: IWeekDate[] = [38 { startDate: new Date('2018-01-22T00:00:00Z'), name: '1', id: '1' },39 { startDate: new Date('2018-01-29T00:00:00Z'), name: '2', id: '2' },40 { startDate: new Date('2018-02-05T00:00:00Z'), name: '3', id: '3' },41 { startDate: new Date('2018-02-12T00:00:00Z'), name: '4', id: '4' },42 { startDate: new Date('2018-02-19T00:00:00Z'), name: '5', id: '5' },43 { startDate: new Date('2018-02-26T00:00:00Z'), name: '6', id: '6' },44 { startDate: new Date('2018-03-05T00:00:00Z'), name: '7', id: '7' },45 { startDate: new Date('2018-03-12T00:00:00Z'), name: '8', id: '8' },46 { startDate: new Date('2018-03-19T00:00:00Z'), name: '9', id: '9' },47 { startDate: new Date('2018-03-25T23:00:00Z'), name: 'Easter Week', id: '10' },48 { startDate: new Date('2018-04-01T23:00:00Z'), name: '10', id: '11' },49 { startDate: new Date('2018-04-08T23:00:00Z'), name: '11', id: '12' },50 { startDate: new Date('2018-04-15T23:00:00Z'), name: '12', id: '13' },51 { startDate: new Date('2018-04-22T23:00:00Z'), name: '13', id: '14' },52 ];53 it('parses week details', () => {54 expect(parseWeekDates($)).toEqual(mockWeeks);55 });56});57describe('parseModuleDetails()', () => {58 const $ = cheerio.load(moduleDetails);59 const mockModuleDetails: IModuleDetails = {60 id: 'CS4006',61 name: 'INTELLIGENT SYSTEMS',62 };63 it('parses module details', () => {64 expect(parseModuleDetails($)).toEqual(mockModuleDetails);65 });66});67describe('parseModuleExamTimetable()', () => {68 const $ = cheerio.load(moduleExamTimetable);69 const mockModuleExamTimetable: IModuleExamTimetable = {70 moduleId: 'CS4006',71 roomIds: ['EGO10'],72 date: new Date('2018-05-05T15:00:00.000Z'),73 info: '',74 };75 it('parses module exam timetables', () => {76 expect(parseModuleExamTimetable($)).toEqual(mockModuleExamTimetable);77 });78});79describe('parseStudentExamTimetable()', () => {80 const $ = cheerio.load(studentExamTimetable);81 const mockStudentExamTimetable: IModuleExamTimetable[] = [{82 date: new Date('2018-05-02T11:30:00.000Z'),83 info: '',84 moduleId: 'CS4115',85 roomIds: ['PG053'],86 }, {87 date: new Date('2018-05-05T15:00:00.000Z'),88 info: '',89 moduleId: 'CS4006',90 roomIds: ['EGO10'],91 }, {92 date: new Date('2018-05-09T08:00:00.000Z'),93 info: '',94 moduleId: 'CS4076',95 roomIds: ['PG053'],96 }, {97 date: new Date('2018-05-11T15:00:00.000Z'),98 info: '',99 moduleId: 'CS4187',100 roomIds: ['C1058', 'C1059', 'C1060', 'C1061', 'C1062'],101 }];102 it('parses student exam timetables', () => {103 expect(parseStudentExamTimetable($)).toEqual(mockStudentExamTimetable);104 });105});106describe('parseTimetable()', () => {107 it('parses course timetables using the supplied lesson parser', () => {108 const $ = cheerio.load(courseTimetable);109 const mockParse = jest.fn(() => ({}));110 expect(parseTimetable($, mockParse)).toEqual({111 [Day.Monday]: [{}, {}, {}, {}, {}, {}, {}, {}],112 [Day.Tuesday]: [{}, {}, {}, {}, {}, {}, {}],113 [Day.Wednesday]: [{}, {}, {}, {}, {}, {}, {}, {}],114 [Day.Thursday]: [{}, {}, {}, {}, {}, {}, {}],115 [Day.Friday]: [{}, {}, {}, {}, {}, {}, {}, {}, {}],116 [Day.Saturday]: [],117 });118 const lessons = [119 ['09:00', '10:00', 'CS4416', 'LEC', ' ', 'NIKOLOV NIKOLA DR', 'CSG001', 'Wks:1-9,11-13\n '],120 ['10:00', '11:00', 'CS4416', 'TUT', '3C', 'NIKOLOV NIKOLA DR', 'CSG025', 'Wks:1-9,11-13\n '],121 ['10:00', '12:00', 'CS4084', 'LAB', '2C', 'BOTTERWECK GOETZ DR', 'CS2044', 'Wks:1-9,11-13\n '],122 ['11:00', '12:00', 'EE4013', 'LAB', '2B', 'MURPHY KEVIN DR', 'B2005', 'Wks:1-9,11-13\n '],123 ['12:00', '13:00', 'CS4004', 'LEC', ' ', 'POWER NORAH DR', 'D1050', 'Wks:1-9,11-13\n '],124 ['13:00', '14:00', 'CS4014', 'LEC', ' ', 'RYAN CONOR PROFESSOR', 'S205', 'Wks:1-5\n '],125 ['15:00', '16:00', 'CS4014', 'LAB', '2A', 'RYAN CONOR PROFESSOR', 'CS2044', 'Wks:1-5\n '],126 ['17:00', '18:00', 'EE4013', 'LEC', ' ', 'MURPHY KEVIN DR', 'C1063', 'Wks:1-9,11-13\n '],127 ['09:00', '11:00', 'CS4084', 'LAB', '2B', 'BOTTERWECK GOETZ DR', 'CS2044', 'Wks:1-9,11-13\n '],128 ['11:00', '12:00', 'CS4416', 'LAB', '2A', 'NIKOLOV NIKOLA DR', 'CS2044', 'Wks:1-9,11-13\n '],129 ['12:00', '13:00', 'CS4416', 'LAB', '2C', 'NIKOLOV NIKOLA DR', 'CS2044', 'Wks:1-9,11-13\n '],130 ['13:00', '14:00', 'CS4416', 'LAB', '2E', 'NIKOLOV NIKOLA DR', 'CS2044', 'Wks:1-9,11-13\n '],131 ['14:00', '15:00', 'CS4416', 'LAB', '2D', 'NIKOLOV NIKOLA DR', 'CS2044', 'Wks:1-9,11-13\n '],132 ['15:00', '16:00', 'CS4084', 'TUT', '3B', 'BOTTERWECK GOETZ DR', 'SG18', 'Wks:1-9,11-13\n '],133 ['16:00', '17:00', 'CS4084', 'LEC', ' ', 'BOTTERWECK GOETZ DR', 'KBG12', 'Wks:1-9,11-13\n '],134 ['09:00', '10:00', 'EE4013', 'LAB', '2A', 'MURPHY KEVIN DR', 'B2005', 'Wks:1-9,11-13\n '],135 ['09:00', '10:00', 'CS4004', 'LAB', '2B', 'POWER NORAH DR', 'CS1044', 'Wks:1-9,11-13\n '],136 ['09:00', '10:00', 'CS4416', 'LAB', '2B', 'NIKOLOV NIKOLA DR', 'CS2044', 'Wks:1-9,11-13\n '],137 ['10:00', '11:00', 'CS4416', 'TUT', '3B', 'NIKOLOV NIKOLA DR', 'SG19', 'Wks:1-9,11-13\n '],138 ['11:00', '12:00', 'CS4416', 'TUT', '3A', 'NIKOLOV NIKOLA DR', 'SG16', 'Wks:1-9,11-13\n '],139 ['12:00', '13:00', 'CS4004', 'LAB', '2D', 'POWER NORAH DR', 'CS1044', 'Wks:1-9,11-13\n '],140 ['13:00', '14:00', 'CS4416', 'TUT', '3D', 'NIKOLOV NIKOLA DR', 'CSG025', 'Wks:1-9,11-13\n '],141 ['14:00', '15:00', 'CS4416', 'LEC', ' ', 'NIKOLOV NIKOLA DR', 'FB028', 'Wks:1-9,11-13\n '],142 ['09:00', '10:00', 'CS4416', 'TUT', '3E', 'NIKOLOV NIKOLA DR', 'S116', 'Wks:1-9,11-13\n '],143 ['10:00', '11:00', 'CS4004', 'LAB', '2A', 'POWER NORAH DR', 'CS1044', 'Wks:1-9,11-13\n '],144 ['10:00', '11:00', 'CS4084', 'TUT', '3C', 'BOTTERWECK GOETZ DR', 'SG19', 'Wks:1-9,11-13\n '],145 ['12:00', '13:00', 'EE4013', 'LAB', '2C', 'MURPHY KEVIN DR', 'B2005', 'Wks:1-9,11-13\n '],146 ['13:00', '14:00', 'CS4004', 'LEC', ' ', 'POWER NORAH DR', 'CSG001', 'Wks:1-9,11-13\n '],147 ['14:00', '15:00', 'CS4014', 'LEC', ' ', 'RYAN CONOR PROFESSOR', 'S206', 'Wks:1-5\n '],148 ['15:00', '17:00', 'CS4084', 'LAB', '2A', 'BOTTERWECK GOETZ DR', 'CS2044', 'Wks:1-9,11-13\n '],149 ['09:00', '10:00', 'CS4084', 'TUT', '3A', 'BOTTERWECK GOETZ DR', 'S114', 'Wks:1-9,11-13\n '],150 ['09:00', '10:00', 'CS4004', 'TUT', '3B', 'POWER NORAH DR', 'SG19', 'Wks:1-9,11-13\n '],151 ['10:00', '11:00', 'CS4004', 'TUT', '3C', 'POWER NORAH DR', 'SG19', 'Wks:1-9,11-13\n '],152 ['11:00', '12:00', 'CS4084', 'LEC', ' ', 'BOTTERWECK GOETZ DR', 'C1063', 'Wks:1-9,11-13\n '],153 ['11:00', '12:00', 'CS4004', 'TUT', '3A', 'POWER NORAH DR', 'SG19', 'Wks:1-9,11-13\n '],154 ['12:00', '13:00', 'EE4013', 'LEC', ' ', 'MURPHY KEVIN DR', 'FG042', 'Wks:1-9,11-13\n '],155 ['14:00', '15:00', 'CS4014', 'LEC', ' ', 'RYAN CONOR PROFESSOR', 'S205', 'Wks:1-5\n '],156 ['15:00', '16:00', 'CS4004', 'TUT', '3D', 'POWER NORAH DR', 'SG19', 'Wks:1-9,11-13\n '],157 ['16:00', '17:00', 'CS4004', 'LAB', '2C', 'POWER NORAH DR', 'CS1044', 'Wks:1-9,11-13\n '],158 ];159 for (const lesson of lessons) {160 expect(mockParse).toBeCalledWith(lesson);161 }162 });163 it('parses module timetables using the supplied lesson parser', () => {164 const $ = cheerio.load(moduleTimetable);165 const mockParse = jest.fn(() => ({}));166 expect(parseTimetable($, mockParse)).toEqual({167 [Day.Monday]: [{}, {}],168 [Day.Tuesday]: [{}, {}],169 [Day.Wednesday]: [],170 [Day.Thursday]: [{}],171 [Day.Friday]: [{}],172 [Day.Saturday]: [],173 });174 const lessons = [175 ['09:00', '10:00', 'TUT', '3A', 'EATON MALACHY DR', 'SG19', 'Wks:1-9,11-13\n '],176 ['11:00', '12:00', 'LEC', ' ', 'EATON MALACHY DR', 'KBG13', 'Wks:1-9,11-13\n '],177 ['09:00', '10:00', 'TUT', '3B', 'EATON MALACHY DR', 'SG19', 'Wks:1-9,11-13\n '],178 ['10:00', '11:00', 'LAB', '2A', 'EATON MALACHY DR', 'CS3005B', 'Wks:1-9,11-13\n '],179 ['12:00', '13:00', 'LEC', ' ', 'EATON MALACHY DR', 'KBG13', 'Wks:1-9,11-13\n '],180 ['09:00', '10:00', 'LAB', '2B', 'EATON MALACHY DR', 'CS3005B', 'Wks:1-9,11-13\n '],181 ];182 for (const lesson of lessons) {183 expect(mockParse).toBeCalledWith(lesson);184 }185 });186 it('parses room timetables using the supplied lesson parser', () => {187 const $ = cheerio.load(roomTimetable);188 const mockParse = jest.fn(() => ({}));189 expect(parseTimetable($, mockParse)).toEqual({190 [Day.Monday]: [{}, {}, {}, {}, {}, {}, {}, {}],191 [Day.Tuesday]: [{}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}],192 [Day.Wednesday]: [{}, {}, {}, {}, {}, {}, {}],193 [Day.Thursday]: [{}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}],194 [Day.Friday]: [{}, {}, {}, {}, {}, {}, {}],195 [Day.Saturday]: [],196 });197 const lessons = [198 ['09:00', '10:00', 'CS4416', 'LEC', '', 'Size - 141', 'NIKOLOV NIKOLA DR', 'Wks:1-9,11-13\n '],199 ['10:00', '11:00', 'PS4052', 'LEC', '', 'Size - 93', 'O'BRIEN SANDRA MS', 'Wks:1-2,4-5,8-9,11\n '],200 ['11:00', '12:00', 'RM4002 RM4006', 'TUT', '3A 3A', 'Size - 189', 'RIEDER MARIA MS', 'Wks:7,9,11\n '],201 ['12:00', '13:00', 'MK4025', 'LEC', '', 'Size - 135', 'PATTERSON MAURICE DR', 'Wks:1-9,11-13\n '],202 ['13:00', '14:00', 'MA4402', 'LEC', '', 'Size - 116', 'GABURRO ROMINA DR', 'Wks:3-9,11-13\n '],203 ['13:00', '14:00', 'MA4402', 'LEC', '', 'Size - 116', 'HEALY PATRICK DR GABURRO ROMINA DR', 'Wks:1-2\n '],204 ['14:00', '16:00', 'AC4214', 'LEC', '', 'Size - 160', 'BREATHNACH MAIREAD', 'Wks:1-9,11-13\n '],205 ['17:00', '18:00', 'TX4407', 'LEC', '', 'Size - 125', 'MCCARTHY BRENDAN MR', 'Wks:1-9,11-13\n '],206 ['09:00', '11:00', 'NS6038', 'LEC', '', 'Size - 164', 'GRAHAM MARGARET DR MESKELL PAULINE MS', 'Wks:1-2,4,7,11,13\n '],207 ['09:00', '12:00', ' ', 'RMBKG', '', 'Size - 0', ' ', 'Wks:16\n '],208 ['09:00', '11:00', 'NS6038', 'LEC', '1A', 'Size - 50', 'GRAHAM MARGARET DR MESKELL PAULINE MS', 'Wks:3,5-6,8-9,12\n '],209 ['11:00', '12:00', 'AC4004 AC4034', 'LEC', '', 'Size - 201', 'WHELAN JOANNE MS', 'Wks:1-9,11-13\n '],210 ['12:00', '15:00', ' ', 'RMBKG', '', 'Size - 0', ' ', 'Wks:16\n '],211 ['12:00', '13:00', 'TX4407', 'LEC', '', 'Size - 125', 'MCCARTHY BRENDAN MR', 'Wks:1-9,11-13\n '],212 ['14:00', '15:00', 'CS4076', 'LEC', '', 'Size - 50', 'EXTON CHRIS DR', 'Wks:1-9,11-13\n '],213 ['15:00', '18:00', ' ', 'RMBKG', '', 'Size - 0', ' ', 'Wks:16\n '],214 ['15:00', '16:00', 'CS4222 CS5052', 'LEC', '', 'Size - 152', 'MC ELLIGOTT ANNETTE MS', 'Wks:1-9,11-13\n '],215 ['16:00', '17:00', 'CS4049', 'LEC', '', 'Size - 35', 'MCCARTHY LEON MR', 'Wks:1-9,11-13\n '],216 ['17:00', '18:00', 'AC4024', 'LEC', '', 'Size - 209', 'REGAN KATHLEEN', 'Wks:1-9,11-13\n '],217 ['18:00', '19:00', ' ', 'RMBKG', '', 'Size - 0', ' ', 'Wks:9\n '],218 ['09:00', '10:00', 'MK4008', 'LEC', '', 'Size - 71', 'REIDY SEAN MR', 'Wks:1-9,11-13\n '],219 ['10:00', '11:00', 'CS4005', 'LEC', '', 'Size - 64', 'O'CONNOR NEIL MR', 'Wks:1-9,11-13\n '],220 ['11:00', '12:00', 'EC4014', 'LEC', '', 'Size - 185', 'FLANNERY DARRAGH DR', 'Wks:1-9,11-13\n '],221 ['12:00', '15:00', ' ', 'RMBKG', '', 'Size - 0', ' ', 'Wks:16\n '],222 ['12:00', '14:00', 'CS4457', 'LEC', '', 'Size - 146', 'DE WILLE TABEA', 'Wks:1-9,11-13\n '],223 ['14:00', '18:00', ' ', 'RMBKG', '', 'Size - 0', ' ', 'Wks:1-9,11-14\n '],224 ['15:00', '18:00', ' ', 'RMBKG', '', 'Size - 0', ' ', 'Wks:16\n '],225 ['09:00', '10:00', ' ', 'RMBKG', '', 'Size - 65', ' ', 'Wks:3-9,11-13\n '],226 ['09:00', '12:00', ' ', 'RMBKG', '', 'Size - 0', ' ', 'Wks:14-16\n '],227 ['10:00', '11:00', ' ', 'RMBKG', '', 'Size - 0', ' ', 'Wks:3\n '],228 ['11:00', '12:00', 'AC4034 AC4004', 'LEC', '', 'Size - 201', 'WHELAN JOANNE MS', 'Wks:1-9,11-13\n '],229 ['12:00', '13:00', 'MU4136', 'LEC', '', 'Size - 118', 'ANO1HUM', 'Wks:5,11\n '],230 ['12:00', '13:00', 'MU4136', 'LEC', '', 'Size - 118', 'KEEGAN NIALL DR', 'Wks:1,6,12\n '],231 ['12:00', '13:00', 'MU4136', 'LEC', '', 'Size - 118', 'NI BHRIAIN ORFHLAITH DR.', 'Wks:2,7,13\n '],232 ['12:00', '15:00', ' ', 'RMBKG', '', 'Size - 0', ' ', 'Wks:14-16\n '],233 ['12:00', '13:00', 'MU4136', 'LEC', '', 'Size - 118', 'MELIN MATS DR', 'Wks:4,9\n '],234 ['12:00', '13:00', 'MU4136', 'LEC', '', 'Size - 118', 'DOWNEY JEAN MS', 'Wks:3,8\n '],235 ['13:00', '14:00', 'CS4004', 'LEC', '', 'Size - 109', 'POWER NORAH DR', 'Wks:1-9,11-13\n '],236 ['14:00', '15:00', 'CS4911', 'LEC', '', 'Size - 86', 'FITZGERALD BRIAN PROFESSOR', 'Wks:1-9,11-13\n '],237 ['15:00', '18:00', ' ', 'RMBKG', '', 'Size - 0', ' ', 'Wks:14-16\n '],238 ['15:00', '16:00', 'CS5052 CS4222', 'LEC', '', 'Size - 152', 'MC ELLIGOTT ANNETTE MS', 'Wks:1-9,11-13\n '],239 ['16:00', '17:00', ' ', 'RMBKG', '', 'Size - 0', ' ', 'Wks:1\n '],240 ['17:00', '18:00', 'MA4402', 'LEC', '', 'Size - 116', 'GABURRO ROMINA DR', 'Wks:3-9,11-13\n '],241 ['18:00', '20:00', ' ', 'RMBKG', '', 'Size - 0', ' ', 'Wks:1\n '],242 ['09:00', '11:00', 'LA4122', 'LEC', '', 'Size - 167', 'BURNS NORAH MS', 'Wks:1-9,11-13\n '],243 ['09:00', '12:00', ' ', 'RMBKG', '', 'Size - 0', ' ', 'Wks:14-16\n '],244 ['11:00', '13:00', 'AC4418', 'LEC', '', 'Size - 156', 'REGAN KATHLEEN', 'Wks:1-9,11-13\n '],245 ['12:00', '15:00', ' ', 'RMBKG', '', 'Size - 0', ' ', 'Wks:14-16\n '],246 ['13:00', '14:00', 'CS4040', 'LEC', '', 'Size - 31', 'MCCARTHY LEON MR', 'Wks:1-9,11-13\n '],247 ['14:00', '15:00', 'AC4024', 'LEC', '', 'Size - 209', 'REGAN KATHLEEN', 'Wks:1-9,11-13\n '],248 ['15:00', '16:00', 'MS4122', 'LEC', '', 'Size - 69', 'GABURRO ROMINA DR', 'Wks:1-9,11-13\n '],249 ];250 for (const lesson of lessons) {251 expect(mockParse).toBeCalledWith(lesson);252 }253 });254 it('parses student timetables using the supplied lesson parser', () => {255 const $ = cheerio.load(studentTimetable);256 const mockParse = jest.fn(() => ({}));257 expect(parseTimetable($, mockParse)).toEqual({258 [Day.Monday]: [{}, {}, {}, {}],259 [Day.Tuesday]: [{}, {}],260 [Day.Wednesday]: [{}],261 [Day.Thursday]: [{}, {}, {}, {}, {}],262 [Day.Friday]: [{}, {}, {}, {}],263 [Day.Saturday]: [],264 });265 const lessons = [266 ['09:00', '10:00', 'CS4006', 'TUT', '3A', 'SG19', 'Wks:1-9,11-13\n '],267 ['11:00', '12:00', 'CS4006', 'LEC', ' ', 'KBG13', 'Wks:1-9,11-13\n '],268 ['15:00', '17:00', 'CS4076', 'LAB', '2A', 'CS3005B', 'Wks:1-9,11-13\n '],269 ['17:00', '18:00', 'CS4115', 'LEC', ' ', 'KBG13', 'Wks:1-9,11-13\n '],270 ['10:00', '11:00', 'CS4006', 'LAB', '2A', 'CS3005B', 'Wks:1-9,11-13\n '],271 ['14:00', '15:00', 'CS4076', 'LEC', ' ', 'CSG001', 'Wks:1-9,11-13\n '],272 ['12:00', '14:00', 'CS4457', 'LEC', ' ', 'CSG001', 'Wks:1-9,11-13\n '],273 ['09:00', '11:00', 'CS4187', 'LEC', ' ', 'SG16', 'Wks:1-9,11-13\n '],274 ['12:00', '13:00', 'CS4006', 'LEC', ' ', 'KBG13', 'Wks:1-9,11-13\n '],275 ['13:00', '14:00', 'CS4115', 'LEC', ' ', 'KBG13', 'Wks:1-9,11-13\n '],276 ['14:00', '16:00', 'CS4187', 'TUT', '3A', 'KB119', 'Wks:1-9,11-13\n '],277 ['16:00', '17:00', 'CS4457', 'TUT', '3A', 'S115', 'Wks:2-9,11-13\n '],278 ['10:00', '12:00', 'CS4187', 'TUT', '3A', 'SG20', 'Wks:1-9,11-13\n '],279 ['12:00', '13:00', 'CS4076', 'LEC', ' ', 'KBG14', 'Wks:1-9,11-13\n '],280 ['14:00', '15:00', 'CS4115', 'LEC', ' ', 'KBG10', 'Wks:1-9,11-13\n '],281 ['16:00', '17:00', 'CS4115', 'LAB', '2B', 'CS3005B', 'Wks:1-9,11-13\n '],282 ];283 for (const lesson of lessons) {284 expect(mockParse).toBeCalledWith(lesson);285 }286 });287 it('skips lessons with falsey return values from $.html()', () => {288 const $ = cheerio.load(nullTimetable);289 const mockParse = jest.fn(() => ({}));290 expect(parseTimetable($, mockParse)).toEqual({291 [Day.Monday]: [],292 [Day.Tuesday]: [],293 [Day.Wednesday]: [],294 [Day.Thursday]: [],295 [Day.Friday]: [],296 [Day.Saturday]: [],297 });298 expect(mockParse).not.toBeCalled();299 });300});301describe('parseModuleTimetableLesson()', () => {302 it('parses a single lesson from a module timetable', () => {303 const lesson = parseModuleTimetableLesson(moduleTimetableLesson);304 expect(lesson).toEqual({305 fromTime: '09:00',306 toTime: '10:00',307 lessonType: LessonType.LEC,308 group: null,309 instructor: 'EATON MALACHY DR',310 roomIds: ['SG19'],311 weekIds: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '11', '12', '13'],312 });313 });314 it('parses a single group lesson from a module timetable', () => {315 const lesson = parseModuleTimetableLesson(moduleTimetableGroupLesson);316 expect(lesson).toEqual({317 fromTime: '09:00',318 toTime: '10:00',319 lessonType: LessonType.TUT,320 group: '3B',321 instructor: 'EATON MALACHY DR',322 roomIds: ['SG19'],323 weekIds: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '11', '12', '13'],324 });325 });326});327describe('parseRoomTimetableLesson()', () => {328 it('parses a single lesson from a room timetable', () => {329 const lesson = parseRoomTimetableLesson(roomTimetableLesson);330 expect(lesson).toEqual({331 fromTime: '09:00',332 toTime: '11:00',333 moduleIds: ['NS6038'],334 lessonType: LessonType.LEC,335 groups: ['1A'],336 size: 50,337 instructor: 'O\'BRIEN JOANNE MS',338 weekIds: ['3', '5', '6', '8', '9', '12'],339 });340 });341 it('parses a single booking from a room timetable', () => {342 const lesson = parseRoomTimetableLesson(roomTimetableBooking);343 expect(lesson).toEqual({344 fromTime: '14:00',345 toTime: '18:00',346 moduleIds: null,347 lessonType: LessonType.RMBKG,348 size: 0,349 groups: null,350 instructor: null,351 weekIds: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '11', '12', '13', '14'],352 });353 });354});355describe('parseCourseTimetableLesson()', () => {356 it('parses a single lesson from a course timetable', () => {357 const lesson = parseCourseTimetableLesson(courseTimetableLesson);358 expect(lesson).toEqual({359 fromTime: '09:00',360 toTime: '10:00',361 moduleId: 'CS4416',362 lessonType: LessonType.LEC,363 group: null,364 instructor: 'NIKOLOV NIKOLA DR',365 roomIds: ['CSG001'],366 weekIds: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '11', '12', '13'],367 });368 });369 it('parses a single group lesson from a course timetable', () => {370 const lesson = parseCourseTimetableLesson(courseTimetableGroupLesson);371 expect(lesson).toEqual({372 fromTime: '10:00',373 toTime: '11:00',374 moduleId: 'CS4416',375 lessonType: LessonType.TUT,376 group: '3C',377 instructor: 'NIKOLOV NIKOLA DR',378 roomIds: ['CSG025'],379 weekIds: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '11', '12', '13'],380 });381 });382});383describe('parseStudentTimetableLesson()', () => {384 it('parses a single lesson from a student timetable', () => {385 const lesson = parseStudentTimetableLesson(studentTimetableLesson);386 expect(lesson).toEqual({387 fromTime: '13:00',388 toTime: '14:00',389 moduleId: 'CS4115',390 lessonType: LessonType.LEC,391 group: null,392 roomIds: ['KBG13'],393 weekIds: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '11', '12', '13'],394 });395 });396 it('parses a single group lesson from a student timetable', () => {397 const lesson = parseStudentTimetableLesson(studentTimetableGroupLesson);398 expect(lesson).toEqual({399 fromTime: '14:00',400 toTime: '16:00',401 moduleId: 'CS4187',402 lessonType: LessonType.TUT,403 group: '3A',404 roomIds: ['KB119'],405 weekIds: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '11', '12', '13'],406 });407 });...

Full Screen

Full Screen

webKey.jsm

Source:webKey.jsm Github

copy

Full Screen

1/*global Components: false */2/*3 * This Source Code Form is subject to the terms of the Mozilla Public4 * License, v. 2.0. If a copy of the MPL was not distributed with this5 * file, You can obtain one at http://mozilla.org/MPL/2.0/.6 */7/* eslint no-invalid-this: 0 */8/**9 * This module serves to integrate WKS (Webkey service) into Enigmail10 */11"use strict";12var EXPORTED_SYMBOLS = ["EnigmailWks"];13const Cu = Components.utils;14const Cc = Components.classes;15const Ci = Components.interfaces;16Cu.import("resource://enigmail/files.jsm"); /* global EnigmailFiles: false */17Cu.import("resource://enigmail/subprocess.jsm"); /*global subprocess: false */18Cu.import("resource://enigmail/log.jsm"); /*global EnigmailLog: false */19Cu.import("resource://enigmail/core.jsm"); /*global EnigmailCore: false */20Cu.import("resource://enigmail/execution.jsm"); /*global EnigmailExecution: false */21Cu.import("resource://enigmail/gpgAgent.jsm"); /*global EnigmailGpgAgent: false */22Cu.import("resource://enigmail/stdlib.jsm"); /*global EnigmailStdlib: false */23const GPG_WKS_CLIENT = "gpg-wks-client";24var EnigmailWks = {25 wksClientPath: null,26 /**27 * Get WKS Client path (gpg-wks-client)28 *29 * @param window: Object - parent window for dialog display30 * @param cb : Function(retValue) - callback function.31 * retValue: nsIFile Object to gpg-wks-client executable or NULL32 */33 getWksClientPathAsync: function(window, cb) {34 EnigmailLog.DEBUG("webKey.jsm: getWksClientPathAsync\n");35 if (EnigmailWks.wksClientPath === null) {36 let listener = EnigmailExecution.newSimpleListener(null, function(ret) {37 if (ret === 0) {38 try {39 let stdout = listener.stdoutData;40 let libexecdir = /^libexecdir:(.+?)$/m.exec(stdout)[1];41 if (libexecdir) {42 libexecdir = libexecdir.replace(/%3a/gi, ":");43 }44 else {45 libexecdir = "";46 }47 let wks_client = checkIfExists(libexecdir, GPG_WKS_CLIENT);48 if (!wks_client) {49 let bindir = /^bindir:(.+?)$/m.exec(stdout)[1];50 if (bindir) {51 bindir = bindir.replace(/%3a/gi, ":");52 }53 else {54 bindir = "";55 }56 wks_client = checkIfExists(bindir, GPG_WKS_CLIENT);57 if (!wks_client) {58 cb(null);59 return;60 }61 }62 EnigmailWks.wksClientPath = wks_client;63 cb(wks_client);64 }65 catch (e) {66 EnigmailLog.DEBUG("webKey.jsm: getWksClientPathAsync: " + e.toString() + "\n");67 cb(null);68 }69 }70 else {71 cb(null);72 }73 });74 return EnigmailExecution.execStart(EnigmailGpgAgent.gpgconfPath, ["--list-dirs"], false, window, listener, {75 value: null76 });77 }78 else {79 cb(EnigmailWks.wksClientPath);80 return null;81 }82 },83 /**84 * Determine if WKS is supported by email provider85 *86 * @param email : String - user's email address87 * @param window: Object - parent window of dialog display88 * @param cb : Function(retValue) - callback function.89 * retValue: Boolean: true if WKS is supported / false otherwise90 */91 isWksSupportedAsync: function(email, window, cb) {92 EnigmailLog.DEBUG("webKey.jsm: isWksSupportedAsync: email = " + email + "\n");93 return EnigmailWks.getWksClientPathAsync(window, function(wks_client) {94 if (wks_client === null) {95 cb(false);96 }97 let listener = EnigmailExecution.newSimpleListener(null, function(ret) {98 cb(ret === 0);99 });100 let proc = EnigmailExecution.execStart(wks_client, ["--supported", email], false, window, listener, {101 value: null102 });103 if (proc === null) {104 cb(false);105 }106 });107 },108 /**109 * Submit a key to the email provider (= send publication request)110 *111 * @param ident : nsIMsgIdentity - user's ID112 * @param key : Enigmail KeyObject of user's key113 * @param window: Object - parent window of dialog display114 * @param cb : Function(retValue) - callback function.115 * retValue: Boolean: true if submit was successful / false otherwise116 */117 submitKey: function(ident, key, window, cb) {118 EnigmailLog.DEBUG("webKey.jsm: submitKey: email = " + ident.email + "\n");119 return EnigmailWks.getWksClientPathAsync(window, function(wks_client) {120 if (wks_client === null) {121 cb(false);122 return;123 }124 let listener = EnigmailExecution.newSimpleListener(null, function(ret) {125 if (ret !== 0) {126 cb(false);127 return;128 }129 EnigmailLog.DEBUG("webKey.jsm: submitKey: send " + listener.stdoutData + "\n");130 let si = Components.classes["@mozdev.org/enigmail/composefields;1"].createInstance(Components.interfaces.nsIEnigMsgCompFields);131 let subject = listener.stdoutData.match(/^Subject:[ \t]*(.+)$/im);132 let to = listener.stdoutData.match(/^To:[ \t]*(.+)$/im);133 if (subject !== null && to !== null) {134 si.sendFlags |= (Ci.nsIEnigmail.SEND_VERBATIM);135 EnigmailStdlib.sendMessage({136 urls: [],137 identity: ident,138 to: to[1],139 subject: subject[1],140 securityInfo: si141 }, {142 compType: Ci.nsIMsgCompType.New,143 deliveryType: Ci.nsIMsgCompDeliverMode.Now144 }, {145 match: function(x) {146 x.plainText(listener.stdoutData);147 }148 }, {}, {});149 if (cb !== null) {150 cb(true);151 }152 else {153 cb(false);154 }155 }156 });157 EnigmailExecution.execStart(wks_client, ["--create", key.fpr, ident.email], false, window, listener, {158 value: null159 });160 });161 },162 /**163 * Submit a key to the email provider (= send publication request)164 *165 * @param ident : nsIMsgIdentity - user's ID166 * @param body : String - complete message source of the confirmation-request email obtained167 * from the email provider168 * @param window: Object - parent window of dialog display169 * @param cb : Function(retValue) - callback function.170 * retValue: Boolean: true if submit was successful / false otherwise171 */172 confirmKey: function(ident, body, window, cb) {173 var sanitized = body.replace(/\r?\n/g, "\r\n");174 EnigmailLog.DEBUG("webKey.jsm: confirmKey: ident=" + ident.email + "\n");175 return EnigmailWks.getWksClientPathAsync(window, function(wks_client) {176 if (wks_client === null) {177 if (cb) {178 cb(false);179 }180 return;181 }182 let listener = EnigmailExecution.newSimpleListener(function(pipe) {183 try {184 pipe.write(sanitized);185 pipe.close();186 }187 catch (e) {188 if (cb) {189 cb(false);190 }191 EnigmailLog.DEBUG(e + "\n");192 }193 }, function(ret) {194 try {195 let si = Components.classes["@mozdev.org/enigmail/composefields;1"].createInstance(Components.interfaces.nsIEnigMsgCompFields);196 let subject = listener.stdoutData.match(/^Subject:[ \t]*(.+)$/im);197 let to = listener.stdoutData.match(/^To:[ \t]*(.+)$/im);198 if (subject !== null && to !== null) {199 si.sendFlags |= (Ci.nsIEnigmail.SEND_VERBATIM);200 EnigmailStdlib.sendMessage({201 urls: [],202 identity: ident,203 to: to[1],204 subject: subject[1],205 securityInfo: si206 }, {207 compType: Ci.nsIMsgCompType.New,208 deliveryType: Ci.nsIMsgCompDeliverMode.Now209 }, {210 match: function(x) {211 x.plainText(listener.stdoutData);212 }213 }, {}, {});214 if (cb) {215 cb(true);216 }217 }218 }219 catch (e) {220 if (cb) {221 cb(false);222 }223 EnigmailLog.DEBUG(e + "\n");224 }225 });226 EnigmailExecution.execStart(wks_client, ["--receive"], false, window, listener, {227 value: null228 });229 });230 }231};232/**233 * Check if a file exists and is executable234 *235 * @param path: String - directory name236 * @param execFileName: String - executable name237 *238 * @return Object - nsIFile if file exists; NULL otherwise239 */240function checkIfExists(path, execFileName) {241 let file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);242 execFileName = EnigmailFiles.potentialWindowsExecutable(execFileName);243 EnigmailFiles.initPath(file, path);244 file.append(execFileName);245 if (file.exists() && file.isExecutable()) {246 return file;247 }248 else {249 return null;250 }...

Full Screen

Full Screen

workspace.dom.ts

Source:workspace.dom.ts Github

copy

Full Screen

1/**2 * Copyright (C) 2018-2020 Linagora3 *4 * This program is free software: you can redistribute it and/or modify5 * it under the terms of the GNU Affero General Public License as6 * published by the Free Software Foundation, either version 3 of the7 * License, or (at your option) any later version.8 *9 * This program is distributed in the hope that it will be useful,10 * but WITHOUT ANY WARRANTY; without even the implied warranty of11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12 * GNU Affero General Public License for more details.13 *14 * You should have received a copy of the GNU Affero General Public License15 * along with this program. If not, see <http://www.gnu.org/licenses/>.16 */17// base selector18const bs = `app-workspace`;19const bsWksDeletionDiag = `app-workspace-deletion-dialog`;20const bsWksDeletedDiag = `app-workspace-deleted-dialog`;21const bsWksElement = `app-workspace-element`;22const bsWksOverview = `app-workspace-overview`;23const bsWksBusDetachDiag = `app-bus-detach-dialog`;24const bsWksBusImportDiag = `app-bus-import-dialog`;25export const WORKSPACE_DOM = {26 buttons: {27 workspaceName: `${bs} .btn-workspace-name`,28 changeWorkspace: `${bs} .btn-change-workspace`,29 },30 menu: { workspaceMenu: `${bs} .workspace-menu` },31 tabs: `${bs} .mat-tab-label`,32 sidenav: {33 workspaceSidenav: `${bs} .mat-sidenav-container .workspace-sidenav`,34 },35};36export const WORKSPACE_DELETION_DIALOG_DOM = {37 buttons: {38 cancel: `${bsWksDeletionDiag} .btn-cancel-delete-wks`,39 submit: `${bsWksDeletionDiag} .btn-confirm-delete-wks`,40 },41 dialog: { dialogDeletionWks: `${bsWksDeletionDiag}` },42 texts: {43 infoTitle: `${bsWksDeletionDiag} .mat-dialog-title span span`,44 description: `${bsWksDeletionDiag} .mat-dialog-content p`,45 },46};47export const WORKSPACE_DELETED_DIALOG_DOM = {48 buttons: { ok: `${bsWksDeletedDiag} button` },49 dialog: { dialogDeletedWks: `${bsWksDeletedDiag}` },50 texts: {51 infoTitle: `${bsWksDeletedDiag} .mat-dialog-title span span`,52 description: `${bsWksDeletedDiag} .mat-dialog-content div p`,53 },54};55export const WORKSPACE_ELEMENT_DOM = {56 workspaceElement: {57 workspaceElementView: `${bsWksElement} .workspace-element`,58 },59};60export const WORKSPACE_OVERVIEW_DOM = {61 buttons: {62 openDialogDeleteWks: `${bsWksOverview} .btn-delete-wks`,63 addEditWorkspaceDetails: `${bsWksOverview} .btn-add-edit-workspace-details`,64 cancelEditWorkspaceDetails: `${bsWksOverview} .btn-cancel-edit-workspace-details`,65 saveWorkspaceDetails: `${bsWksOverview} .btn-save-workspace-details`,66 editDetachBus: `${bsWksOverview} .btn-detach-bus`,67 cancelDetachBus: `${bsWksOverview} .btn-cancel-detach-bus`,68 openDialogDetachBus: `${bsWksOverview} .btn-open-detach-bus-dialog`,69 editImportBus: `${bsWksOverview} .btn-import-bus`,70 cancelAttachBus: `${bsWksOverview} .btn-cancel-attach-bus`,71 importNewBus: `${bsWksOverview} .btn-import-new-bus`,72 addUserInWorkspace: `${bsWksOverview} .btn-add-user`,73 savePermissionsBtn: `${bsWksOverview} .btn-save-users-permissions`,74 },75 formFields: {76 workspaceNameFormField: `${bsWksOverview} .wks-name-form-field`,77 shortDescriptionFormField: `${bsWksOverview} .short-description-form-field`,78 descriptionFormField: `${bsWksOverview} .description-form-field`,79 ipFormField: `${bsWksOverview} .bus-import-edit .ip-form-field`,80 portFormField: `${bsWksOverview} .bus-import-edit .port-form-field`,81 usernameFormField: `${bsWksOverview} .bus-import-edit .username-form-field`,82 passwordFormField: `${bsWksOverview} .bus-import-edit .pwd-form-field`,83 passphraseFormField: `${bsWksOverview} .bus-import-edit .passphrase-form-field`,84 addUserFormField: `${bsWksOverview} .add-user-form-field`,85 },86 inputs: {87 ip: `${bsWksOverview} input[formcontrolname="ip"]`,88 port: `${bsWksOverview} input[formcontrolname="port"]`,89 username: `${bsWksOverview} input[formcontrolname="username"]`,90 password: `${bsWksOverview} input[formcontrolname="password"]`,91 passphrase: `${bsWksOverview} input[formcontrolname="passphrase"]`,92 userSearchCtrl: `${bsWksOverview} input[formcontrolname="userSearchCtrl"]`,93 workspaceName: `${bsWksOverview} input[formcontrolname="workspaceName"]`,94 },95 listGridItem: {96 itemBus: `${bsWksOverview} .bus-grid-item .bus-item .bus-link`,97 itemDetachBus: `${bsWksOverview} .bus-grid-item .bus-item .bus-detach`,98 },99 messages: {100 nothingToPreview: `${bsWksOverview} workspace-description-edit div .msg-no-description`,101 importBusDetailsError: `${bsWksOverview} .error-import-details`,102 },103 texts: {104 busNames: `${bsWksOverview} .bus-grid-item .bus-item .bus-link .bus-footer .bus-name`,105 busDetachNames: `${bsWksOverview} .bus-grid-item .bus-item .bus-detach .bus-footer .bus-name`,106 shortDescription: `${bsWksOverview} .short-description-text`,107 description: `${bsWksOverview} .description-text`,108 descriptionPreview: `${bsWksOverview} .workspace-description-preview`,109 candidateListIds: `.mat-option span`,110 },111 textArea: {112 shortDescriptionTextarea: `${bsWksOverview} textarea.short-description-wks`,113 descriptionTextarea: `${bsWksOverview} textarea.description-wks`,114 },115 table: {116 userTable: `${bsWksOverview} .users-table`,117 texts: { headerTable: `${bsWksOverview} .mat-header-cell` },118 rows: {119 allRow: `${bsWksOverview} .table-row`,120 userRow: (userId: string) => `${bsWksOverview} .row-${userId}`,121 },122 cells: {123 userId: (userId: string) => `${bsWksOverview} .cell-userid-${userId}`,124 userName: (userId: string) => `${bsWksOverview} .cell-username-${userId}`,125 userAdminWorkspace: (userId: string) =>126 `${bsWksOverview} .cell-user-adminWorkspace-${userId} mat-checkbox [type="checkbox"]`,127 userDeployArtifact: (userId: string) =>128 `${bsWksOverview} .cell-user-deployArtifact-${userId} mat-checkbox [type="checkbox"]`,129 userLifecycleArtifact: (userId: string) =>130 `${bsWksOverview} .cell-user-lifecycleArtifact-${userId} mat-checkbox [type="checkbox"]`,131 userActionDelete: (userId: string) =>132 `${bsWksOverview} .cell-user-action-${userId} .action-delete`,133 currentUserDelete: `${bsWksOverview} .action-leave-wks`,134 },135 },136};137export const WORKSPACE_BUS_DETACH_DIALOG_DOM = {138 buttons: {139 cancel: `${bsWksBusDetachDiag} .btn-cancel-detach-bus-dialog`,140 submit: `${bsWksBusDetachDiag} .btn-confirm-detach-bus-dialog`,141 },142 dialog: { dialogDetachBus: `${bsWksBusDetachDiag}` },143 texts: {144 infoTitle: `${bsWksBusDetachDiag} .mat-dialog-title span span`,145 description: `${bsWksBusDetachDiag} .mat-dialog-content p`,146 },147};148export const WORKSPACE_BUS_IMPORT_DIALOG_DOM = {149 buttons: {150 cancel: `${bsWksBusImportDiag} .btn-cancel-import-bus-dialog`,151 },152 dialog: { dialogImportBus: `${bsWksBusImportDiag}` },153 texts: {154 infoTitle: `${bsWksBusImportDiag} .mat-dialog-title span span`,155 },...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools')2var page = wptools.page('Albert Einstein')3page.get_wikidata(function(data){4 console.log(data)5})6{ error: 'no wikidata for Albert Einstein' }

Full Screen

Using AI Code Generation

copy

Full Screen

1var wk = require('wks')2 if (err) throw err3 console.log(data)4})5var wk = require('wks')6 if (err) throw err7 console.log(data)8})9var wk = require('wks')10 if (err) throw err11 console.log(data)12})13var wk = require('wks')14 if (err) throw err15 console.log(data)16})17var wk = require('wks')18 if (err) throw err19 console.log(data)20})21var wk = require('wks')22 if (err) throw err23 console.log(data)24})25var wk = require('wks')26 if (err) throw err27 console.log(data)28})29var wk = require('wks')30 if (err) throw err31 console.log(data)32})

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var fs = require('fs');3var test = wpt('www.webpagetest.org', 'A.0b0d0e0a05d1a9b78e3b1b3d3a3c3e0f');4 if (err) {5 console.log('Error: ' + err);6 } else {7 console.log('Test Status: ' + data.statusCode);8 console.log('Test ID: ' + data.data.testId);9 console.log('Test URL: ' + data.data.summary);10 console.log('Test Result URL: ' + data.data.userUrl);11 console.log('Test

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var options = {3};4var webpagetest = wpt(options);5}, function (err, data) {6 if (err) return console.error(err);7 console.log(data);8 console.log(data.data.median.firstView.SpeedIndex);9 console.log(data.data.median.firstView.SpeedIndex);10 console.log(data

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful