Skip to content

Commit a524ab1

Browse files
committed
fix: move ai_spec to correct directory
1 parent d0040be commit a524ab1

2 files changed

Lines changed: 48 additions & 0 deletions

File tree

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# frozen_string_literal: true
2+
3+
require 'spec_helper'
4+
5+
describe Crowdin::ApiResources::Ai do
6+
describe '#ai_translate_strings' do
7+
let(:user_id) { 1 }
8+
9+
context 'in Crowdin mode (non-enterprise)' do
10+
it 'when request are valid' do
11+
stub_request(:post, "https://api.crowdin.com/api/v2/users/#{user_id}/ai/translations/translate-strings")
12+
.to_return(
13+
status: 200,
14+
body: {
15+
data: {
16+
translations: ['Hallo Welt']
17+
}
18+
}.to_json
19+
)
20+
21+
result = @crowdin.ai_translate_strings(user_id, { strings: ['Hello'], targetLanguageId: 'de' })
22+
expect(result['data']['translations']).to eq(['Hallo Welt'])
23+
end
24+
end
25+
26+
context 'in Enterprise mode', :enterprise do
27+
it 'when request are valid' do
28+
stub_request(:post, "https://#{organization_domain}.api.crowdin.com/api/v2/ai/translations/translate-strings")
29+
.to_return(
30+
status: 200,
31+
body: {
32+
data: {
33+
translations: ['Hallo Welt']
34+
}
35+
}.to_json
36+
)
37+
38+
result = @crowdin.ai_translate_strings(user_id, { strings: ['Hello'], targetLanguageId: 'de' })
39+
expect(result['data']['translations']).to eq(['Hallo Welt'])
40+
end
41+
end
42+
43+
it 'should raise error when user_id is missing' do
44+
expect { @crowdin.ai_translate_strings(nil, { strings: ['Hello'] }) }
45+
.to raise_error(ArgumentError)
46+
end
47+
end
48+
end

0 commit comments

Comments
 (0)