@@ -7,21 +7,22 @@ var beforeEach = require('mocha').beforeEach;
77var afterEach = require ( 'mocha' ) . afterEach ;
88var expect = require ( 'chai' ) . expect ;
99var mockFs = require ( 'mock-fs' ) ;
10- var CancellationToken = require ( '../../lib/CancellationToken' ) . CancellationToken ;
10+ var CancellationToken = require ( '../../lib/CancellationToken' )
11+ . CancellationToken ;
1112
12- describe ( '[UNIT] CancellationToken' , function ( ) {
13- beforeEach ( function ( ) {
13+ describe ( '[UNIT] CancellationToken' , function ( ) {
14+ beforeEach ( function ( ) {
1415 var fsTree = { } ;
1516 fsTree [ os . tmpdir ( ) ] = mockFs . directory ( ) ;
1617
1718 mockFs ( fsTree ) ;
1819 } ) ;
1920
20- afterEach ( function ( ) {
21+ afterEach ( function ( ) {
2122 mockFs . restore ( ) ;
2223 } ) ;
2324
24- it ( 'should create valid cancellation token' , function ( ) {
25+ it ( 'should create valid cancellation token' , function ( ) {
2526 var tokenA = new CancellationToken ( ) ;
2627 expect ( tokenA . isCancellationRequested ( ) ) . to . be . false ;
2728
@@ -35,42 +36,54 @@ describe('[UNIT] CancellationToken', function () {
3536 expect ( tokenD . isCancellationRequested ( ) ) . to . be . true ;
3637 } ) ;
3738
38- it ( 'should serialize to JSON' , function ( ) {
39+ it ( 'should serialize to JSON' , function ( ) {
3940 var tokenA = new CancellationToken ( ) ;
4041 var json = JSON . stringify ( tokenA ) ;
4142
4243 expect ( json ) . to . be . a ( 'string' ) ;
43- expect ( function ( ) { JSON . parse ( json ) ; } ) . to . not . throw ( Error ) ;
44+ expect ( function ( ) {
45+ JSON . parse ( json ) ;
46+ } ) . to . not . throw ( Error ) ;
4447 expect ( JSON . parse ( json ) ) . to . be . a ( 'object' ) ;
4548
4649 var tokenB = CancellationToken . createFromJSON ( JSON . parse ( json ) ) ;
47- expect ( tokenA . getCancellationFilePath ( ) ) . to . be . equal ( tokenB . getCancellationFilePath ( ) ) ;
48- expect ( tokenA . isCancellationRequested ( ) ) . to . be . equal ( tokenB . isCancellationRequested ( ) ) ;
50+ expect ( tokenA . getCancellationFilePath ( ) ) . to . be . equal (
51+ tokenB . getCancellationFilePath ( )
52+ ) ;
53+ expect ( tokenA . isCancellationRequested ( ) ) . to . be . equal (
54+ tokenB . isCancellationRequested ( )
55+ ) ;
4956 } ) ;
5057
51- it ( 'should generate path in os.tmpdir() directory' , function ( ) {
58+ it ( 'should generate path in os.tmpdir() directory' , function ( ) {
5259 var tokenA = new CancellationToken ( ) ;
5360
54- expect ( tokenA . getCancellationFilePath ( ) . indexOf ( os . tmpdir ( ) ) ) . to . be . equal ( 0 ) ;
61+ expect ( tokenA . getCancellationFilePath ( ) . indexOf ( os . tmpdir ( ) ) ) . to . be . equal (
62+ 0
63+ ) ;
5564 } ) ;
5665
57- it ( 'should throw ts.OperationCanceledException error on cancelled' , function ( ) {
66+ it ( 'should throw ts.OperationCanceledException error on cancelled' , function ( ) {
5867 var tokenA = new CancellationToken ( ) ;
59- expect ( function ( ) { tokenA . throwIfCancellationRequested ( ) ; } ) . to . not . throw ( ) ;
68+ expect ( function ( ) {
69+ tokenA . throwIfCancellationRequested ( ) ;
70+ } ) . to . not . throw ( ) ;
6071
6172 var tokenB = new CancellationToken ( 'rgeer#R23r$#T$3t#$t43' , true ) ;
62- expect ( function ( ) { tokenB . throwIfCancellationRequested ( ) ; } ) . to . throw ( ts . OperationCanceledException ) ;
73+ expect ( function ( ) {
74+ tokenB . throwIfCancellationRequested ( ) ;
75+ } ) . to . throw ( ts . OperationCanceledException ) ;
6376 } ) ;
6477
65- it ( 'should write file in filesystem on requestCancellation' , function ( ) {
78+ it ( 'should write file in filesystem on requestCancellation' , function ( ) {
6679 var tokenA = new CancellationToken ( ) ;
6780 tokenA . requestCancellation ( ) ;
6881
6982 expect ( tokenA . isCancellationRequested ( ) ) . to . be . true ;
7083 expect ( fs . existsSync ( tokenA . getCancellationFilePath ( ) ) ) . to . be . true ;
7184 } ) ;
7285
73- it ( 'should cleanup file on cleanupCancellation' , function ( ) {
86+ it ( 'should cleanup file on cleanupCancellation' , function ( ) {
7487 var tokenA = new CancellationToken ( ) ;
7588 tokenA . requestCancellation ( ) ;
7689 tokenA . cleanupCancellation ( ) ;
@@ -79,18 +92,24 @@ describe('[UNIT] CancellationToken', function () {
7992 expect ( fs . existsSync ( tokenA . getCancellationFilePath ( ) ) ) . to . be . false ;
8093
8194 // make sure we can call it as many times as we want to
82- expect ( function ( ) { tokenA . cleanupCancellation ( ) ; } ) . to . not . throw ( Error ) ;
95+ expect ( function ( ) {
96+ tokenA . cleanupCancellation ( ) ;
97+ } ) . to . not . throw ( Error ) ;
8398 expect ( tokenA . isCancellationRequested ( ) ) . to . be . false ;
8499 } ) ;
85100
86- it ( 'should not throw error on cleanupCancellation with no file exists' , function ( ) {
101+ it ( 'should not throw error on cleanupCancellation with no file exists' , function ( ) {
87102 var tokenA = new CancellationToken ( 'some_file_that_doesnt_exists' , true ) ;
88103
89- expect ( function ( ) { tokenA . cleanupCancellation ( ) ; } ) . to . not . throw ( ) ;
90- expect ( function ( ) { tokenA . cleanupCancellation ( ) ; } ) . to . not . throw ( ) ;
104+ expect ( function ( ) {
105+ tokenA . cleanupCancellation ( ) ;
106+ } ) . to . not . throw ( ) ;
107+ expect ( function ( ) {
108+ tokenA . cleanupCancellation ( ) ;
109+ } ) . to . not . throw ( ) ;
91110 } ) ;
92111
93- it ( 'should throttle check for 10ms' , function ( done ) {
112+ it ( 'should throttle check for 10ms' , function ( done ) {
94113 var tokenA = new CancellationToken ( ) ;
95114 var tokenB = CancellationToken . createFromJSON ( tokenA . toJSON ( ) ) ;
96115 var start = Date . now ( ) ;
@@ -107,7 +126,7 @@ describe('[UNIT] CancellationToken', function () {
107126 expect ( tokenB . isCancellationRequested ( ) ) . to . be . false ;
108127 }
109128
110- setTimeout ( function ( ) {
129+ setTimeout ( function ( ) {
111130 expect ( tokenB . isCancellationRequested ( ) ) . to . be . true ;
112131 done ( ) ;
113132 } , 11 ) ;
0 commit comments