Sha256: 9fd5e07543f1c98a22678124f04a23bd0a4825ee68a0fbfb6888edae9576ff05

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 KB

Contents

require 'spec_helper'
require 'browser/history'

describe Browser::History do
  describe '#current' do
    it 'should return the current location' do
      $window.history.current.should == '/'
    end
  end

  describe '#push' do
    it 'should change location' do
      $window.history.current.should == '/'
      $window.history.push('/lol')
      $window.history.current.should == '/lol'
      $window.history.push('/')
      $window.history.current.should == '/'
    end
  end

  describe '#back' do
    async 'should go back once' do
      $window.history.current.should == '/'
      $window.history.push('/wut')
      $window.history.current.should == '/wut'

      $window.on 'pop:state' do |e|
        run_async {
          $window.history.current.should == '/'
        }

        e.off
      end

      $window.history.back
    end
  end

  describe '#state' do
    it 'gets the right state' do
      $window.history.push('/wut', 42)
      $window.history.state.should == 42
      $window.history.push('/omg', 23)
      $window.history.state.should == 23
      $window.history.back(2)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
opal-browser-0.1.0.beta1 spec/history_spec.rb