How to use expectCount method in wpt

Best JavaScript code snippet using wpt

reuse-tab.component.spec.ts

Source:reuse-tab.component.spec.ts Github

copy

Full Screen

...122 describe('[default]', () => {123 it(124 'should be create an instance',125 fakeAsync(() => {126 page.expectCount(1);127 }),128 );129 it(130 'should be add a tab when route changed',131 fakeAsync(() => {132 page.to('#b').expectCount(2);133 }),134 );135 it(136 'should be change tab via click',137 fakeAsync(() => {138 expect(layoutComp.change).not.toHaveBeenCalled();139 page.to('#b').go(0);140 expect(layoutComp.change).toHaveBeenCalled();141 }),142 );143 it(144 'should be two tab in routing parameters',145 fakeAsync(() => {146 page147 .to('#b')148 .tap(() => {149 page.getEl('#b2').click();150 page.advance();151 })152 .expectCount(3);153 }),154 );155 });156 describe('#close', () => {157 it(158 'should be close a tab',159 fakeAsync(() => {160 page161 .to('#b')162 .expectUrl(0, '/a')163 .expectUrl(1, '/b/1')164 .close(0)165 .expectUrl(0, '/b/1');166 expect(layoutComp.close).toHaveBeenCalled();167 }),168 );169 it(170 'should keep one tab when [showCurrent: true]',171 fakeAsync(() => {172 page173 .to('#b')174 .expectCount(2)175 .close(0)176 .expectCount(1);177 expect(document.querySelectorAll('.anticon-close').length).toBe(0);178 }),179 );180 it(181 'should close all tab when [showCurrent: false]',182 fakeAsync(() => {183 layoutComp.showCurrent = false;184 fixture.detectChanges();185 page186 .to('#b')187 .expectCount(1)188 .close(0)189 .expectCount(0);190 expect(page.getEl('reuse-tab').style.display).toBe('none');191 }),192 );193 it(194 'should show next tab when closed a has next tab',195 fakeAsync(() => {196 srv.max = 10;197 page198 .to('#b')199 .to('#c')200 .go(1)201 // a, b/1, c202 .expectUrl(1, '/b/1')203 .close(1)204 .expectUrl(1, '/c');205 }),206 );207 it(208 'issues-363',209 fakeAsync(() => {210 page211 .to('#b')212 .expectCount(2)213 .close(1)214 .expectCount(1)215 .expectAttr(0, 'closable', false);216 }),217 );218 });219 describe('#title', () => {220 it(221 `should reset title via component`,222 fakeAsync(() => {223 page.to('#c');224 expect(page.list[page.count - 1].title).toBe(`new c title`);225 }),226 );227 });228 describe('[property]', () => {229 describe('#showCurrent', () => {230 it(231 'with true',232 fakeAsync(() => {233 layoutComp.showCurrent = true;234 fixture.detectChanges();235 page236 .to('#b')237 .expectCount(2)238 .expectUrl(0, '/a')239 .expectUrl(1, '/b/1')240 .to('#c')241 .expectCount(3)242 .expectUrl(0, '/a')243 .expectUrl(1, '/b/1')244 .expectUrl(2, '/c');245 }),246 );247 it(248 'with false',249 fakeAsync(() => {250 layoutComp.showCurrent = false;251 fixture.detectChanges();252 page253 .to('#b')254 .expectCount(1)255 .expectUrl(0, '/a')256 .to('#c')257 .expectCount(2)258 .expectUrl(1, '/b/1');259 }),260 );261 });262 describe('#mode', () => {263 [264 ReuseTabMatchMode.Menu,265 ReuseTabMatchMode.MenuForce,266 ReuseTabMatchMode.URL,267 ].forEach(type => {268 it(`with ${type}`, () => {269 layoutComp.mode = type;270 fixture.detectChanges();271 expect(srv.mode).toBe(type);272 });273 });274 });275 describe('#debug', () => {276 [true, false].forEach(type => {277 it(`with ${type}`, () => {278 layoutComp.debug = type;279 fixture.detectChanges();280 expect(srv.debug).toBe(type);281 });282 });283 });284 describe('#max', () => {285 it(286 'with 2',287 fakeAsync(() => {288 const MAX = 2;289 layoutComp.max = MAX;290 fixture.detectChanges();291 page292 .to('#b')293 .expectCount(MAX)294 .to('#c')295 .expectCount(MAX + (layoutComp.showCurrent ? 1 : 0))296 .to('#d')297 .expectCount(MAX + (layoutComp.showCurrent ? 1 : 0));298 }),299 );300 });301 describe('#allowClose', () => {302 it(303 'with true',304 fakeAsync(() => {305 layoutComp.allowClose = true;306 fixture.detectChanges();307 page.to('#b');308 expect(dl.queryAll(By.css('.op')).length).toBe(2);309 page.to('#c');310 expect(dl.queryAll(By.css('.op')).length).toBe(3);311 }),312 );313 it(314 'with false',315 fakeAsync(() => {316 layoutComp.allowClose = false;317 fixture.detectChanges();318 page.to('#b');319 expect(dl.queryAll(By.css('.op')).length).toBe(0);320 page.to('#c');321 expect(dl.queryAll(By.css('.op')).length).toBe(0);322 }),323 );324 });325 describe('#fixed', () => {326 it(`with true`, () => {327 layoutComp.fixed = true;328 fixture.detectChanges();329 expect(document.querySelector('body').classList).toContain(330 'has-ad-rt',331 );332 expect(dl.query(By.css('.fixed'))).not.toBeNull();333 });334 it(`with false`, () => {335 layoutComp.fixed = false;336 fixture.detectChanges();337 expect(document.querySelector('body').classList).not.toContain(338 'has-ad-rt',339 );340 expect(dl.query(By.css('.fixed'))).toBeNull();341 });342 });343 });344 describe('[context-menu]', () => {345 beforeEach(() => (srv.max = 10));346 it(347 'should closed current tab',348 fakeAsync(() => {349 expect(layoutComp.close).not.toHaveBeenCalled();350 page351 .to('#b')352 .expectCount(2)353 .openContextMenu(1)354 .clickContentMenu('close')355 .expectCount(1);356 expect(layoutComp.close).toHaveBeenCalled();357 }),358 );359 it(360 'should keeping tab if closed include multi prev tab',361 fakeAsync(() => {362 let cTime: string;363 page364 .to('#b') // 1365 .to('#c') // 2366 .tap(() => (cTime = page.time))367 .to('#d') // 3368 .go(2)369 .expectCount(4)370 .openContextMenu(1)371 .clickContentMenu('close')372 .expectCount(3)373 .expectActive(1, true)374 .expectUrl(1, '/c')375 .expectTime(cTime);376 }),377 );378 it(379 'should show the previous tab if the right not tab',380 fakeAsync(() => {381 let aTime: string;382 page383 .tap(() => (aTime = page.time))384 .to('#b') // 1385 .expectCount(2)386 .openContextMenu(1)387 .clickContentMenu('close')388 .expectCount(1)389 .expectActive(0, true)390 .expectUrl(0, '/a')391 .expectTime(aTime);392 }),393 );394 it(395 'should show next tab if closed include multi right tab',396 fakeAsync(() => {397 let cTime: string;398 page399 .to('#b') // 1400 .to('#c') // 2401 .tap(() => (cTime = page.time))402 .to('#d') // 3403 .go(1)404 .expectCount(4)405 .openContextMenu(1)406 .clickContentMenu('close')407 .expectCount(3)408 .expectActive(1, true)409 .expectUrl(1, '/c')410 .expectTime(cTime);411 }),412 );413 it(414 'should keeping tab when closed prev tab',415 fakeAsync(() => {416 page417 .to('#b')418 .expectCount(2)419 .openContextMenu(0)420 .clickContentMenu('close')421 .expectCount(1)422 .expectActive(0, true);423 }),424 );425 it(426 'should keeping tab when closed next tab',427 fakeAsync(() => {428 page429 .to('#b')430 .go(0)431 .expectCount(2)432 .openContextMenu(1)433 .clickContentMenu('close')434 .expectCount(1)435 .expectActive(0, true);436 }),437 );438 it(439 'should keeping tab of closed right tab',440 fakeAsync(() => {441 let bTime: string;442 page443 .to('#b') // 1444 .tap(() => (bTime = page.time))445 .to('#c') // 2446 .to('#d') // 3447 .go(1)448 .expectCount(4)449 .openContextMenu(1)450 .clickContentMenu('closeRight')451 .expectCount(2)452 .expectActive(1, true)453 .expectUrl(1, '/b/1')454 .expectTime(bTime);455 }),456 );457 it(458 'should keeping tab of close other tab',459 fakeAsync(() => {460 let bTime: string;461 page462 .to('#b') // 1463 .tap(() => (bTime = page.time))464 .to('#c') // 2465 .to('#d') // 3466 .go(1)467 .expectCount(4)468 .openContextMenu(1)469 .clickContentMenu('closeOther')470 .expectCount(1)471 .expectActive(0, true)472 .expectUrl(0, '/b/1')473 .expectTime(bTime);474 }),475 );476 it(477 'should keeping tab of clear tab',478 fakeAsync(() => {479 let bTime: string;480 page481 .to('#b') // 1482 .tap(() => (bTime = page.time))483 .to('#c') // 2484 .to('#d') // 3485 .go(1)486 .expectCount(4)487 .openContextMenu(1)488 .clickContentMenu('clear')489 .expectCount(1)490 .expectActive(0, true)491 .expectUrl(0, '/b/1')492 .expectTime(bTime);493 }),494 );495 it(496 'should trigger off close when closable: false',497 fakeAsync(() => {498 page499 .to('#b')500 .tap(() => (srv.closable = false))501 .openContextMenu(1)502 .expectCount(2)503 .clickContentMenu('close')504 .expectCount(2);505 }),506 );507 it(508 'should trigger off closeRight when is last',509 fakeAsync(() => {510 page511 .to('#b')512 .openContextMenu(1)513 .expectCount(2)514 .clickContentMenu('closeRight')515 .expectCount(2);516 }),517 );518 it(519 'should hide context menu via click',520 fakeAsync(() => {521 page522 .to('#b')523 .openContextMenu(1)524 .expectCount(2);525 expect(document.querySelectorAll('.reuse-tab-cm').length).toBe(1);526 document.dispatchEvent(new Event('click'));527 page.advance();528 expect(document.querySelectorAll('.reuse-tab-cm').length).toBe(0);529 }),530 );531 it(532 'should be allow multi context menu',533 fakeAsync(() => {534 page535 .to('#b')536 .openContextMenu(1)537 .expectCount(2);538 expect(document.querySelectorAll('.reuse-tab-cm').length).toBe(1);539 document.dispatchEvent(new MouseEvent('click', { button: 2 }));540 page.advance();541 expect(document.querySelectorAll('.reuse-tab-cm').length).toBe(1);542 }),543 );544 it(545 'should be include non-closeable when push ctrl key',546 fakeAsync(() => {547 page548 .to('#e')549 .openContextMenu(1)550 .tap(() =>551 expect(552 document.querySelector(`.reuse-tab-cm li[data-type="close"]`)553 .classList,554 ).toContain('ant-menu-item-disabled'),555 )556 .openContextMenu(1, { ctrlKey: true })557 .tap(() =>558 expect(559 document.querySelector(`.reuse-tab-cm li[data-type="close"]`)560 .classList,561 ).not.toContain('ant-menu-item-disabled'),562 )563 .expectCount(2);564 }),565 );566 });567 describe('[routing]', () => {568 it(569 '[ng-alain #326] should be restricted by canDeactivate when changing tab',570 fakeAsync(() => {571 let lTime: string;572 page573 .to('#leave')574 .tap(() => (lTime = page.time))575 .expectCount(2)576 .expectActive(0, false)577 .expectActive(1, true)578 .go(0)579 .expectActive(0, false)580 .expectActive(1, true)581 .expectTime(lTime);582 }),583 );584 });585 });586 describe('[i18n]', () => {587 it(588 'should be rendered',589 fakeAsync(() => {590 genModule(true);591 page.to('#e').expectAttr(1, 'title', 'zh');592 i18nResult = 'en';593 injector.get(ALAIN_I18N_TOKEN).use('en');594 tick(101);595 page.expectAttr(1, 'title', 'en');596 }),597 );598 });599 class PageObject {600 constructor() {601 this.to('#a');602 }603 tap(cb: () => void): this {604 cb();605 return this;606 }607 get time(): string {608 return this.getEl('#time').innerHTML.trim();609 }610 getEl(cls: string): HTMLElement {611 return dl.query(By.css(cls)).nativeElement as HTMLElement;612 }613 advance(time = 0): this {614 tick(time);615 fixture.detectChanges();616 return this;617 }618 to(id: string): this {619 this.getEl(id).click();620 this.advance();621 return this;622 }623 get list() {624 return rtComp.list;625 }626 get count(): number {627 return this.list.length;628 }629 expectCount(count: number): this {630 expect(page.count).toBe(count);631 return this;632 }633 expectUrl(pos: number, url: string): this {634 expect(this.list[pos].url).toBe(url);635 return this;636 }637 expectAttr(pos: number, attrName: string, value: any): this {638 expect(this.list[pos][attrName]).toBe(value);639 return this;640 }641 expectActive(pos: number, result: boolean): this {642 expect(this.list[pos].active).toBe(result);643 return this;...

Full Screen

Full Screen

select_spec.js

Source:select_spec.js Github

copy

Full Screen

...19 sp.clearName();20 expect(sp.pick(0)).toBe('Select');21 });22 it('can search by name', () => {23 expectCount(10);24 sp.enterSearch('Gandalf the Grey');25 expectCount(0);26 sp.clearSearch();27 sp.enterSearch('lars');28 expectCount(2);29 });30 function expectCount(count) {31 expect(sp.archetypeCount()).toBe(count);32 }33 it('can search by category', () => {34 expectCount(10);35 sp.clickPill('Sex', 'Female');36 expectCount(2);37 sp.clickPill('Sex', 'Male');38 expectCount(5);39 sp.clickPill('Sex', 'Other');40 expectCount(3);41 sp.clickPill('Sex', 'All');42 expectCount(10);43 });44 it('should support filter combinations', () => {45 sp.clickPill('Sex', 'Male');46 sp.enterSearch('lars');47 expectCount(1);48 sp.clickPill('Race', 'Droid');49 expectCount(0);50 });...

Full Screen

Full Screen

counter.service.spec.ts

Source:counter.service.spec.ts Github

copy

Full Screen

1import { first } from 'rxjs/operators';2import { CounterService } from './counter.service';3describe('CounterService', () => {4 let counterService: CounterService;5 function expectCount(count: number): void {6 let actualCount: number | undefined;7 counterService8 .getCount()9 .pipe(first())10 .subscribe((actualCount2) => {11 actualCount = actualCount2;12 });13 expect(actualCount).toBe(count);14 }15 beforeEach(() => {16 counterService = new CounterService();17 });18 it('returns the count', () => {19 expectCount(0);20 });21 it('increments the count', () => {22 counterService.increment();23 expectCount(1);24 });25 it('decrements the count', () => {26 counterService.decrement();27 expectCount(-1);28 });29 it('resets the count', () => {30 const newCount = 123;31 counterService.reset(newCount);32 expectCount(newCount);33 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1wpt.expectCount(2);2wpt.expectCount(1);3wpt.expectCount(1);4wpt.expectCount(1);5wpt.expectCount(1);6wpt.expectCount(1);7wpt.expectCount(1);8wpt.expectCount(1);9wpt.expectCount(1);10### wpt.expectCount(number)11wpt.expectCount(2);12wpt.expectCount(1);13wpt.expectCount(1);14### wpt.expect(value)15wpt.expect(1 === 1);16### wpt.expectNot(value)

Full Screen

Using AI Code Generation

copy

Full Screen

1expectCount(1);2expectCount(0);3expectCount(1);4expectCount(0);5expectCount(1);6expectCount(0);7expectCount(1);8expectCount(0);9expectCount(1);10expectCount(0);11expectCount(1);12expectCount(0);13expectCount(1);14expectCount(0);15expectCount(1);16expectCount(0);17expectCount(1);18expectCount(0);19expectCount(1);20expectCount(0);21expectCount(1);22expectCount(0);23expectCount(1);24expectCount(0);25expectCount(1);26expectCount(0);27expectCount(1

Full Screen

Using AI Code Generation

copy

Full Screen

1expectCount(1);2assert(true, 'assert message');3assert_equals(1, 1, 'assert_equals message');4assert_not_equals(1, 2, 'assert_not_equals message');5assert_approx_equals(1, 1.1, 0.2, 'assert_approx_equals message');6assert_less_than(1, 2, 'assert_less_than message');7assert_less_than_equals(1, 2, 'assert_less_than_equals message');8assert_greater_than(2, 1, 'assert_greater_than message');9assert_greater_than_equals(2, 1, 'assert_greater_than_equals message');10assert_true(true, 'assert_true message');11assert_false(false, 'assert_false message');12assert_array_equals([1, 2, 3], [1, 2, 3], 'assert_array_equals message');13assert_object_equals({ a: 1, b: 2 }, { a: 1, b: 2 }, 'assert_object_equals message');14assert_regexp_match('foo', /foo/, 'assert_regexp_match message');15assert_not_regexp_match('foo', /bar/, 'assert_not_regexp_match message');16assert_class_string(1, 'Number', 'assert_class_string message');17assert_own_property({ a: 1, b: 2 }, 'a', 'assert_own_property message');18assert_inherits({ a: 1, b: 2 }, 'a', '

Full Screen

Using AI Code Generation

copy

Full Screen

1exports.test = function() {2 expectCount(2);3 var a = 2;4 var b = 3;5 var c = a + b;6 assertEqual(c, 5);7 assertEqual(c, 6);8};9exports.test = function() {10 expectCount(1);11 var a = 2;12 var b = 3;13 var c = a + b;14 assertEqual(c, 5);15};16exports.test = function() {17 expectCount(3);18 var a = 2;19 var b = 3;20 var c = a + b;21 assertEqual(c, 5);22 assertEqual(c, 6);23};24exports.test = function() {25 expectCount(2);26 var a = 2;27 var b = 3;28 var c = a + b;29 assertEqual(c, 5);30 assertEqual(c, 6);31};32exports.test = function() {33 expectCount(2);34 var a = 2;35 var b = 3;36 var c = a + b;37 assertEqual(c, 5);38 assertEqual(c, 6);39};40exports.test = function() {41 expectCount(2);42 var a = 2;43 var b = 3;44 var c = a + b;45 assertEqual(c, 5);46 assertEqual(c, 6);47};48exports.test = function() {49 expectCount(2);50 var a = 2;51 var b = 3;52 var c = a + b;53 assertEqual(c, 5);54 assertEqual(c, 6);55};56exports.test = function() {57 expectCount(2);58 var a = 2;

Full Screen

Using AI Code Generation

copy

Full Screen

1expectCount(2);2assert(true, "assertion 1");3assert(false, "assertion 2");4reportResult("This is a test result");5reportCompare("This is a test compare");6reportCompare("This is a test compare");7expectCount(2);8assert(true, "assertion 1");9assert(false, "assertion 2");10reportResult("This is a test result");11reportCompare("This is a test compare");12reportCompare("This is a test compare");13expectCount(2);14assert(true, "assertion 1");15assert(false, "assertion 2");16reportResult("This is a test result");17reportCompare("This is a test compare");18reportCompare("This is a test compare");19expectCount(2);20assert(true, "assertion 1");21assert(false, "assertion 2");22reportResult("This is a test result");23reportCompare("This is a test compare");24reportCompare("This is a test compare");25expectCount(2);26assert(true, "assertion 1");27assert(false, "assertion 2");28reportResult("This is a test result");

Full Screen

Using AI Code Generation

copy

Full Screen

1expectCount(1);2expect(true).toBe(true);3expect(true).toBe(true);4expect({a: 1}).toEqual({a: 1});5expectCount(1);6describe('group1', () => {7 test('test1', () => {8 expect(true).toBe(true);9 });10 test('test2', () => {11 expect(true).toBe(true);12 });13});14test('test1', () => {15 expect(true).toBe(true);16});17beforeAll(() => {18});

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