<commit_before>/* global TWEEN */

import test from 'ava'

import { Easing, Tween, Timeline, update, getAll, removeAll } from './src'

import browserTestMiddleware from './withPage'

test('Events', (t) => {
  let tween = new Tween({ x: 0 })
    .to({ x: 100 }, 100)
    .repeat(2)
    .yoyo(true)
    .start(0)

  t.plan(9)

  tween.on('start', () => {
    t.log('on:start was called successfully')
    t.pass()
  })

  tween.on('update', () => {
    t.log('on:update was called successfully')
    t.pass()
  })

  tween.on('repeat', () => {
    t.log('on:repeat was called successfully')
    t.pass()
  })

  tween.on('reverse', () => {
    t.log('on:reverse was called successfully')
    t.pass()
  })

  tween.on('complete', () => {
    t.log('on:complete was called successfully')
    t.pass()
  })

  update(0)
  update(50)
  update(100)
  update(200)
  update(300)
})

test('Value Interpolation', (t) => {
  let obj = { a: 0, b: 'B value 1', c: { x: 2 }, d: [3], _e: 4, g: 5, h: 0, j: 0, k: '#000' }

  Object.defineProperty(obj, 'e', {
    get () {
      return obj._e
    },
    set (x) {
      obj._e = x
    }
  })

  new Tween(obj)
    .to(
      {
        a: 1,
        b: 'B value 2',
        c: { x: 3 },
        d: [4],
        _e: 5,
        g: '+=1',
        h: 250000,
        j: [1, 2],
        k: ['rgb(100, 100, 100)', 'rgb(200, 200, 200)']
      },
      100
    )
    .start(0)

  update(0)

  t.is(obj.a, 0)
  t.is(obj.b, 'B value 1')
  t.is(obj.c.x, 2)
  t.is(obj.d[0], 3)
  t.is(obj.e, 4)
  t.is(obj.g, 5)
  t.is(obj.h, 0)
  t.is(obj.j, 0)
  t.is(obj.k, 'rgb(0, 0, 0)')

  update(50)

  t.is(obj.a, 0.5, 'Number interpolation not worked as excepted')
  t.log('Number interpolation worked as excepted')

  t.is(obj.b, 'B value 1.5', 'String interpolation not worked as excepted')
  t.log('String interpolation worked as excepted')

  t.is(obj.c.x, 2.5, 'Object interpolation not worked as excepted')
  t.log('Object interpolation worked as excepted')

  t.is(obj.d[0], 3.5, 'Array interpolation not worked as excepted')
  t.log('Array interpolation worked as excepted')

  t.is(obj.e, 4.5, 'Getter/Setter interpolation not worked as excepted')
  t.log('Getter/Setter interpolation worked as excepted')

  t.is(obj.g, 5.5, 'Relative number interpolation not worked as excepted')
  t.log('Relative number interpolation worked as excepted')

  t.is(obj.h, 125000, 'Big number interpolation not worked as excepted')
  t.log('Big number interpolation worked as excepted')

  t.is(obj.j, 1, 'Multi-Interpolation not worked as excepted')
  t.log('Multi-Interpolation worked as excepted')

  t.is(obj.k, 'rgb(100, 100, 100)', 'Multi-Interpolation not worked as excepted')
  t.log('Multi-Interpolation worked as excepted')

  update(100)

  t.is(obj.a, 1)
  t.is(obj.b, 'B value 2')
  t.is(obj.c.x, 3)
  t.is(obj.d[0], 4)
  t.is(obj.e, 5)
  t.is(obj.g, 6)
  t.is(obj.h, 250000, 'Big number interpolation ending value not worked as excepted')
  t.is(obj.j, 2, 'Multi-Interpolation not worked as excepted')
  t.is(obj.k, 'rgb(200, 200, 200)', 'Multi-Interpolation not worked as excepted')
})

test('Value Array-based Interpolation', (t) => {
  let obj = { x: 0 }
  new Tween(obj).to({ x: [1, 3, 5] }, 100).start(0)

  t.is(obj.x, 0)

  update(50)

  t.is(obj.x, 2, 'Interpolation failed')
  t.log('End-value interpolation was done')

  t.log('Start-value interpolation was done')

  update(100)
})

test('Tweens List Controlling', (t) => {
  let tween = new Tween({ x: 0 })
    .to({ x: 100 }, 100)
    .repeat(2)
    .yoyo(true)
    .start(0)

  t.is(getAll().length, 1, 'Tween added in tweens list')
  t.log('Tweens adding was done')

  tween.stop()<commit_msg>add some test<commit_after>/* global TWEEN */

import test from 'ava'

import { Easing, Tween, Timeline, update, getAll, removeAll } from './src'

import browserTestMiddleware from './withPage'

test('Events', (t) => {
  let tween = new Tween({ x: 0 })
    .to({ x: 100 }, 100)
    .repeat(2)
    .yoyo(true)
    .start(0)

  t.plan(9)

  tween.on('start', () => {
    t.log('on:start was called successfully')
    t.pass()
  })

  tween.on('update', () => {
    t.log('on:update was called successfully')
    t.pass()
  })

  tween.on('repeat', () => {
    t.log('on:repeat was called successfully')
    t.pass()
  })

  tween.on('reverse', () => {
    t.log('on:reverse was called successfully')
    t.pass()
  })

  tween.on('complete', () => {
    t.log('on:complete was called successfully')
    t.pass()
  })

  update(0)
  update(50)
  update(100)
  update(200)
  update(300)
})

test('Value Interpolation', (t) => {
  let obj = { a: 0, b: 'B value 1', c: { x: 2 }, d: [3], _e: 4, g: 5, h: 0, j: 0, k: '#000', l: '#0cf', m: '#fc0' }

  Object.defineProperty(obj, 'e', {
    get () {
      return obj._e
    },
    set (x) {
      obj._e = x
    }
  })

  new Tween(obj)
    .to(
      {
        a: 1,
        b: 'B value 2',
        c: { x: 3 },
        d: [4],
        _e: 5,
        g: '+=1',
        h: 250000,
        j: [1, 2],
        k: ['rgb(100, 100, 100)', 'rgb(200, 200, 200)'],
        l: '#fc0',
        m: '#0cf'
      },
      100
    )
    .start(0)

  update(0)

  t.is(obj.a, 0)
  t.is(obj.b, 'B value 1')
  t.is(obj.c.x, 2)
  t.is(obj.d[0], 3)
  t.is(obj.e, 4)
  t.is(obj.g, 5)
  t.is(obj.h, 0)
  t.is(obj.j, 0)
  t.is(obj.k, 'rgb(0, 0, 0)')
  t.is(obj.l, 'rgb(0, 204, 255)')
  t.is(obj.m, 'rgb(255, 204, 0)')

  update(50)

  t.is(obj.a, 0.5, 'Number interpolation not worked as excepted')
  t.log('Number interpolation worked as excepted')

  t.is(obj.b, 'B value 1.5', 'String interpolation not worked as excepted')
  t.log('String interpolation worked as excepted')

  t.is(obj.c.x, 2.5, 'Object interpolation not worked as excepted')
  t.log('Object interpolation worked as excepted')

  t.is(obj.d[0], 3.5, 'Array interpolation not worked as excepted')
  t.log('Array interpolation worked as excepted')

  t.is(obj.e, 4.5, 'Getter/Setter interpolation not worked as excepted')
  t.log('Getter/Setter interpolation worked as excepted')

  t.is(obj.g, 5.5, 'Relative number interpolation not worked as excepted')
  t.log('Relative number interpolation worked as excepted')

  t.is(obj.h, 125000, 'Big number interpolation not worked as excepted')
  t.log('Big number interpolation worked as excepted')

  t.is(obj.j, 1, 'Multi-Interpolation not worked as excepted')
  t.log('Multi-Interpolation worked as excepted')

  t.is(obj.k, 'rgb(100, 100, 100)', 'Multi-Interpolation not worked as excepted')
  t.log('Multi-Interpolation worked as excepted')

  update(100)

  t.is(obj.a, 1)
  t.is(obj.b, 'B value 2')
  t.is(obj.c.x, 3)
  t.is(obj.d[0], 4)
  t.is(obj.e, 5)
  t.is(obj.g, 6)
  t.is(obj.h, 250000, 'Big number interpolation ending value not worked as excepted')
  t.is(obj.j, 2, 'Multi-Interpolation not worked as excepted')
  t.is(obj.k, 'rgb(200, 200, 200)', 'Multi-Interpolation not worked as excepted')
  t.is(obj.l, 'rgb(255, 204, 0)', 'String interpolation not worked as excepted')
  t.is(obj.m, 'rgb(0, 204, 255)', 'String interpolation not worked as excepted')
})

test('Value Array-based Interpolation', (t) => {
  let obj = { x: 0 }
  new Tween(obj).to({ x: [1, 3, 5] }, 100).start(0)

  t.is(obj.x, 0)

  update(50)

  t.is(obj.x, 2, 'Interpolation failed')
  t.log('End-value interpolation was done')

  t.log('Start-value interpolation was done')

  update(100)
})

test('Tweens List Controlling', (t) => {
  let tween = new Tween({ x: 0 })
    .to({ x: 100 }, 100)
    .repeat(2)
    .yoyo(true)
    .start(0)

  t.is(getAll().length, 1, 'Tween added in tweens list')
  t.log('Tweens adding was done')

  tween.stop()
{'fraction_non_alphanumeric': 0.18524332810047095, 'fraction_numerical': 0.04709576138147567, 'mean_word_length': 2.8436400201106085, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2569707', 'n_tokens_mistral': 3361, 'n_tokens_neox': 3010, 'n_words': 807}