<commit_before>'use strict'

const KeyboardLayout = require('../lib/keyboard-layout')

describe('Keyboard Layout', () => {
  if (process.platform == 'darwin') {
    describe('.getCurrentKeymap()', function () {
      it('returns characters corresponding to the given DOM 3 keyboard event code based on the current keyboard layout', function () {
        const currentLayout = KeyboardLayout.getCurrentKeyboardLayout()
        switch (currentLayout) {
          case 'com.apple.keylayout.Dvorak':
            expect(KeyboardLayout.getCurrentKeymap()['KeyS']).toEqual({
              unmodified: 'o',
              withShift: 'O',
              withOption: 'ø',
              withOptionShift: 'Ø'
            })
            break;
          case 'com.apple.keylayout.US':
            expect(KeyboardLayout.getCurrentKeymap()['KeyS']).toEqual({
              unmodified: 's',
              withShift: 'S',
              withOption: 'ß',
              withOptionShift: 'Í'
            })
            break;
          default:
            throw new Error('No assertion defined for current keyboard layout: ' + currentLayout)
        }
      })<commit_msg>Add tests for getCurrentKeymap on Windows<commit_after>'use strict'

const KeyboardLayout = require('../lib/keyboard-layout')

describe('Keyboard Layout', () => {
  if (process.platform === 'darwin' || process.platform === 'win32') {
    describe('.getCurrentKeymap()', function () {
      it('returns characters corresponding to the given DOM 3 keyboard event code based on the current keyboard layout', function () {
        const currentLayout = KeyboardLayout.getCurrentKeyboardLayout()
        switch (currentLayout) {
          case 'com.apple.keylayout.Dvorak':
            expect(KeyboardLayout.getCurrentKeymap()['KeyS']).toEqual({
              unmodified: 'o',
              withShift: 'O',
              withOption: 'ø',
              withOptionShift: 'Ø'
            })
            break

          case '00010409':
            expect(KeyboardLayout.getCurrentKeymap()['KeyS']).toEqual({
              unmodified: 'o',
              withShift: 'O',
              withAltGr: '',
              withAltGrShift: ''
            })
            break

          case 'com.apple.keylayout.US':
            expect(KeyboardLayout.getCurrentKeymap()['KeyS']).toEqual({
              unmodified: 's',
              withShift: 'S',
              withOption: 'ß',
              withOptionShift: 'Í'
            })
            break;

          case '00000409':
            expect(KeyboardLayout.getCurrentKeymap()['KeyS']).toEqual({
              unmodified: 's',
              withShift: 'S',
              withAltGr: '',
              withAltGrShift: ''
            })
            break

          default:
            throw new Error('No assertion defined for current keyboard layout: ' + currentLayout)
        }
      })
{'fraction_non_alphanumeric': 0.12108559498956159, 'fraction_numerical': 0.006958942240779402, 'mean_word_length': 1.877877877877878, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '215838', 'n_tokens_mistral': 739, 'n_tokens_neox': 748, 'n_words': 167}