Advertisement
Guest User

Untitled

a guest
Oct 19th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. describe('syntax', () => {
  2.   it('knows primitives', () => {
  3.     expect(typeof String()).toBe(); // FIXME
  4.     expect(typeof Date()).toBe(); // FIXME
  5.     expect(typeof new Date()).toBe(); // FIXME
  6.     expect(typeof Symbol()).toBe(); // FIXME
  7.     expect(typeof new Error()).toBe(); // FIXME
  8.  
  9.     expect(typeof Error).toBe(); // FIXME
  10.     expect(typeof Set).toBe(); // FIXME
  11.     expect(typeof WeakMap).toBe(); // FIXME
  12.     expect(typeof Iterable).toBe(); // FIXME
  13.     expect(typeof Int32Array).toBe(); // FIXME
  14.   });
  15.  
  16.   it('copes with objects', () => {
  17.     let obj = { hello: 'Hello' }, hello = 'Hello';
  18.     obj[hello] += ','
  19.     obj.hello += ' world';
  20.     obj['hello'] += '!';
  21.  
  22.     expect(obj['hello']).toBe(); // FIXME
  23.   });
  24.  
  25.   it('knows its json', () => {
  26.     let myObj = {
  27.         a : 'A',
  28.         b : 'B',
  29.         c : {
  30.             d : 'D',
  31.             e : 'E',
  32.             f : {
  33.                 g : 'G'
  34.             },
  35.             h : 'H'
  36.         }
  37.     };
  38.     let { c : { f : { g : foo }, e : baz, b : bar } } = myObj;
  39.     expect(foo).toBe(); // FIXME
  40.     expect(baz).toBe(); // FIXME
  41.     expect(bar).toBe(); // FIXME
  42.   });
  43.  
  44.   it('knows arrays', () => {
  45.     var arr = ['Pierre', 'Paul', 'Jacques'];
  46.     expect(arr.join(', ')).toBe(); // FIXME
  47.     arr.push('Jean');
  48.     expect(arr[0]).toBe(); // FIXME
  49.     expect(arr.length).toBe(); // FIXME
  50.   });
  51.  
  52.   it('knows portability', () => {
  53.     let a = 1, b = 2, c = {one: 1};
  54.  
  55.     const fun = () => {
  56.       a = 11;
  57.       let b = 22;
  58.       c.two = 2;
  59.     }
  60.     fun();
  61.  
  62.     expect(a).toBe(); // FIXME
  63.     expect(b).toBe(); // FIXME
  64.     expect(c.one).toBe(); // FIXME
  65.     expect(c.two).toBe(); // FIXME
  66.  
  67.     function Prefixer(prefix) {
  68.       this.prefix = prefix;
  69.     }
  70.     Prefixer.prototype.prefixArray = function (arr) {
  71.       return arr.map(function (x) {
  72.         return this.prefix + x;
  73.       });
  74.     };
  75.  
  76.     var arr = new Prefixer('a').prefixArray([0,1,2]);
  77.     expect(arr[0]).toEqual(); // FIXME
  78.   });
  79.  
  80.   it('knows maps, filters and reduces', () => {
  81.     expect([
  82.       { name:'Lisa'    , mark:'16' },
  83.       { name:'Pascal'  , mark:'13' },
  84.       { name:'Romain'  , mark:'12' },
  85.       { name:'Lucas'   , mark:'4'  },
  86.       { name:'Aurélie' , mark:'14' }
  87.     ]
  88.     .map(function(student) { student.mark = Number(student.mark); return student })
  89.     .filter(function(student) { return student.mark >= 10 })
  90.     .reduce(function(acc, student) { return student.mark + acc }, 0)).toBe(); // FIXME
  91.   });
  92.  
  93.   it('knows functions', () => {
  94.     function laugh() {
  95.       return
  96.       {
  97.         ha: 'Haha!'
  98.       }
  99.     }
  100.     expect(laugh()).toBe(); // FIXME
  101.   });
  102.  
  103.   describe('setTimeout', () =>  {
  104.     jasmine.clock().install();
  105.  
  106.     let buf = '';
  107.     const funcs = {
  108.       A : () => { buf += 'A'; },
  109.       B : () => { buf += 'B'; },
  110.       C : () => { buf += 'C'; },
  111.       D : () => { buf += 'D'; }
  112.     };
  113.  
  114.     it('knows what execution order means', () => {
  115.       ['A','B','C','D'].forEach((letter, index) => {
  116.         setTimeout(funcs[letter], index * 10);
  117.       });
  118.  
  119.       jasmine.clock().tick(101);
  120.       expect(buf).toBe(); // FIXME
  121.     });
  122.   });
  123.  
  124.   describe('class', () => {
  125.     it('is George Abitbol', () => {
  126.       class FooClass {
  127.         constructor() {
  128.           this.a = 'foo';
  129.           return this;
  130.         }
  131.         static a() {
  132.           return 'bar';
  133.         }
  134.       }
  135.       class BarClass extends FooClass {
  136.         constructor() {
  137.           return [super(), super.a, this.a];
  138.         }
  139.       }
  140.       const bar = new BarClass();
  141.       expect(bar[1]).toBe(); // FIXME
  142.       expect(bar[2]).toBe(); // FIXME
  143.     });
  144.   });
  145.  
  146.   describe('date', () => {
  147.     it('knows about UTC', () => {
  148.       let dateFields = [1970, 0, 1];  // 1 Jan 1970
  149.       expect('Thu, 01 Jan 1970 00:00:00 GMT')
  150.         .toEqual(); // FIXME
  151.     });
  152.   });
  153. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement