import test from 'ava';

test('Can provide context to LMLayer', async t => {
  const LMLayer = require('./').LMLayer;
  const lm = new LMLayer;

  t.plan(1);

  let message = await lm.predictWithContext({
    transform: { insert: 'D', deleteLeft: 0, deleteRight: 0 },
    context: { left: '' }
  });

  let {suggestions} = message;

  t.deepEqual(suggestions, [
    { insert: 'Derek', deleteLeft: 1, deleteRight: 0 }
  ]);
});

@@ -17,16 +17,145 @@
  'ava';%0A
+import %7BLMLayer%7D from './';%0A%0Aconst TYPE_D = %7B insert: 'D', deleteLeft: 0, deleteRight: 0 %7D;%0Aconst EMPTY_CONTEXT = %7B left: '' %7D;%0A%0A
 %0Atest('C
@@ -205,46 +205,19 @@
 %7B%0A  
-const LMLayer = require('./').LMLayer;
+t.plan(1);%0A
 %0A  c
@@ -240,30 +240,16 @@
 Layer;%0A%0A
-  t.plan(1);%0A%0A
   let me
@@ -305,81 +305,38 @@
 rm: 
-%7B insert: 'D', deleteLeft: 0, deleteRight: 0 %7D,%0A    context: %7B left: '' %7D
+TYPE_D, context: EMPTY_CONTEXT
 %0A  %7D
@@ -370,17 +370,16 @@
 essage;%0A
-%0A
   t.deep
@@ -460,12 +460,279 @@
 %7D%0A  %5D);%0A%7D);%0A
+%0A%0Atest('Can reject when predictions crash', async t =%3E %7B%0A  t.plan(1);%0A%0A  const lm = new LMLayer;%0A  try %7B%0A    await lm.predictWithContext(%7B%0A      transform: TYPE_D, context: EMPTY_CONTEXT, customToken: NaN%0A    %7D);%0A    t.fail();%0A  %7D catch (_e) %7B%0A    t.pass();%0A  %7D%0A%7D);%0A%0A

Test for rejection.