<commit_before>import BrowserUiState from '../../../src/browser-ui-state/index'
import {defineSupportCode} from 'cucumber'

//TODO Single entry feature files for all state providers
defineSupportCode(function(context) {
    let Given = context.Given
    let When = context.When
    let Then = context.Then

    let CustomWorld = function() {}

    CustomWorld.prototype.win = {
        innerWidth: 0,
        innerHeight: 0,
        screen: {
            width: 0,
            height: 0
        },
        navigator: {
            userAgent: '',
            standalone: false
        },
        document: {
            documentElement: {
                addEventListener(type, listener, useCapture) { /*NOOP*/ }
            }
        },
        dispatchEvent(event) { /*NOOP*/ }
    }

    CustomWorld.prototype.stateProvider = null
    CustomWorld.prototype.thresholds = {
        landscape : {
            collapsed: null,
            keyboard: null,
        },
        portrait : {
            collapsed: null,
            keyboard: null
        }
    }

    CustomWorld.prototype.browserUiState = null

    CustomWorld.prototype.updateScreen = function(width, height) {
        this.win.screen.width = width
        this.win.screen.height = height
    }

    CustomWorld.prototype.updateWindow = function(width, height) {
        this.win.innerWidth = width
        this.win.innerHeight = height
    }

    context.setWorldConstructor(CustomWorld)

    Given('a user agent equals to {string}', function(userAgent) {
        this.win.navigator.userAgent = userAgent
        this.browserUiState = new BrowserUiState(this.win)
    })

    Given('screen dimensions is {int} x {int}', function(width, height) {
        this.updateScreen(width, height)
    })

    Given('window dimensions is {int} x {int}', function(width, height) {
        this.updateWindow(width, height)
    })

    When('after swipe up window dimensions changes to {int} x {int}', function(width, height) {
        this.updateWindow(width, height)
    })

    When('browser is rotated to portrait', function() { /*NOOP*/ })

    When('screen dimensions changes to {int} x {int}', function(width, height) {
        this.updateScreen(width, height)
    })

    When('window dimensions changes to {int} x {int}', function(width, height) {
        this.updateWindow(width, height)
    })

    Then('browser ui state should be {string}', function(state) {
        if (this.browserUiState.state !== state) {
            throw new Error(`Incorrect browser ui state (${this.browserUiState.state})!`)
        }
    })
})<commit_msg>Minor<commit_after>import BrowserUiState from '../../../src/browser-ui-state/index'
import {defineSupportCode} from 'cucumber'

defineSupportCode(function(context) {
    let Given = context.Given
    let When = context.When
    let Then = context.Then

    let CustomWorld = function() {}

    CustomWorld.prototype.win = {
        innerWidth: 0,
        innerHeight: 0,
        screen: {
            width: 0,
            height: 0
        },
        navigator: {
            userAgent: '',
            standalone: false
        },
        document: {
            documentElement: {
                addEventListener(type, listener, useCapture) { /*NOOP*/ }
            }
        },
        dispatchEvent(event) { /*NOOP*/ }
    }

    CustomWorld.prototype.stateProvider = null
    CustomWorld.prototype.thresholds = {
        landscape : {
            collapsed: null,
            keyboard: null,
        },
        portrait : {
            collapsed: null,
            keyboard: null
        }
    }

    CustomWorld.prototype.browserUiState = null

    CustomWorld.prototype.updateScreen = function(width, height) {
        this.win.screen.width = width
        this.win.screen.height = height
    }

    CustomWorld.prototype.updateWindow = function(width, height) {
        this.win.innerWidth = width
        this.win.innerHeight = height
    }

    context.setWorldConstructor(CustomWorld)

    Given('a user agent equals to {string}', function(userAgent) {
        this.win.navigator.userAgent = userAgent
        this.browserUiState = new BrowserUiState(this.win)
    })

    Given('screen dimensions is {int} x {int}', function(width, height) {
        this.updateScreen(width, height)
    })

    Given('window dimensions is {int} x {int}', function(width, height) {
        this.updateWindow(width, height)
    })

    When('after swipe up window dimensions changes to {int} x {int}', function(width, height) {
        this.updateWindow(width, height)
    })

    When('browser is rotated to portrait', function() { /*NOOP*/ })

    When('screen dimensions changes to {int} x {int}', function(width, height) {
        this.updateScreen(width, height)
    })

    When('window dimensions changes to {int} x {int}', function(width, height) {
        this.updateWindow(width, height)
    })

    Then('browser ui state should be {string}', function(state) {
        if (this.browserUiState.state !== state) {
            throw new Error(`Incorrect browser ui state (${this.browserUiState.state})!`)
        }
    })
})
{'fraction_non_alphanumeric': 0.11831315892229598, 'fraction_numerical': 0.0015618898867629833, 'mean_word_length': 2.258905852417303, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1880087', 'n_tokens_mistral': 1426, 'n_tokens_neox': 1401, 'n_words': 339}