Test Suite

For Interview

by kontrach

HTML

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jasmine/2.4.1/jasmine.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jasmine/2.4.1/jasmine.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jasmine/2.4.1/jasmine-html.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jasmine/2.4.1/boot.min.js"></script>
<script type="text/babel">
	'use strict'; 
   /* MOCKS Section */
	 
   const app = new Main();  
   const mk = { 
    a: [1, 4, 7, 23, 82, 0, 12], 
    b: [24, 84, 3, 0, 1, 8, 4],

    collection: [
      { field: 'type1', value: { dataLeft: 1, dataRight: 0 } }, 
      { field: 'type2', value: { dataLeft: 2, dataRight: 0 } }, 
      { field: 'type0', value: { dataLeft: 0, dataRight: 0 } }, 
      { field: 'type1', value: { dataLeft: 1, dataRight: 1 } }, 
      { field: 'type0', value: { dataLeft: 0, dataRight: 1 } }, 
      { field: 'type0', value: { dataLeft: 0, dataRight: 2 } }, 
      { field: 'type1', value: { dataLeft: 1, dataRight: 2 } }
    ], 
    
    groups:[ 
      {
        "groupName": "type0",
        "groupSource": [
          { "dataLeft": 0, "dataRight": 0, "field": "type0" }, 
          { "dataLeft": 0, "dataRight": 1, "field": "type0" }, 
          { "dataLeft": 0, "dataRight": 2, "field": "type0" }
        ]
      },
      { 
      	"groupName": "type1", 
      	"groupSource": [
          { "dataLeft": 1, "dataRight": 0, "field": "type1" }, 
          { "dataLeft": 1, "dataRight": 1, "field": "type1" }, 
          { "dataLeft": 1, "dataRight": 2, "field": "type1" }
        ]
      }, 
      {
        "groupName": "type2",
        "groupSource": [
        	{ "dataLeft": 2, "dataRight": 0, "field": "type2" }
        ]
      }
    ],

    str: 'This Javascript was born to love you',
    // match must be like this:
    // Thi[s Javascript] wa[s born t]o love you
    left: 's',
    right: 't'
  };  
  
  describe('Pending test (1)...', () => {   
  	let out;
  	beforeAll(() =>...

CSS

/*
*                                 TASKS
*============================================================================= *
* TASK 1: mergeAndSort
	  Please merge two array a and b into solid one and then sort it in ascendant way (from low to high).
    For example:
      a and b are equal [1,2,3] and [6,5,0]
      The result will be equal to [0,1,2,3,5,6]
* ============================================================================= *      
* TASK 2: group
    Transform your input collection into another one grouped by 'field'.
    The following result example you can find in mocks section
* ============================================================================= *
* TASK 3: match
    Please find all substrings in str that located between left and right character.
    Keep in mind that you must find the substring which don't overlap each other and have the maximum possible length:
    For example: 
      str is equal to 'This Javascript was born to love you'
      with the left equal to 's' and the right equal to 't'
      The result will be ['s Javascript', 's born t'] 
      but neither ['s Javascript s born t'] 
      nor ['s Javascript', 'script','s born t'], etc.
* ============================================================================= */

Babel + JSX

'use strict';
/* Implementation Section */

window.Main = class {
  mergeAndSort(a, b) { }
  
  group(collection) { }
  
  match(str, left, right) { }
  
  constructor() {}
}